У меня возникли проблемы с ниже код:Unity 2D ошибка 1061
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
public class FollowPath : MonoBehaviour
{
public enum FollowType
{
MoveTowards,
Lerp
}
public FollowType Type = FollowType.MoveTowards;
public PathDefinition Path;
public float Speed = 1;
public float MaxDistanceToGoal = .1f;
private IEnumerator<Transform> _currentPoint;
public void Start()
{
if (Path == null)
{
Debug.LogError("Path cannot be null", gameObject);
return;
}
_currentPoint = Path.GetPathEnumerator();
_currentPoint.MoveNext();
if (_currentPoint.Current == null)
return;
transform.position = _currentPoint.Current.position;
}
public void Update()
{
if (_currentPoint == null || _currentPoint.Current == null)
return;
if (Type == FollowType.MoveTowards)
transform.position = Vector3.MoveTowards (transform.position,
_currentPoint.Current.position, Time.deltaTime * Speed);
else if (Type == FollowType.Lerp)
transform.position = Vector3.Lerp(transform.position,
_currentPoint.Current.position, Time.deltaTime * Speed);
var distanceSquared = (transform.position -
_currentPoint.Current.position).sqrMagnitude;
if (distanceSquared < MaxDistanceToGoal * MaxDistanceToGoal)
_currentPoint.MoveNext();
}
}
Здесь ошибка я получаю:
Активы/Код/FollowPath.cs (28,36): ошибка CS1061: Введите
PathDefinition' does not contain a definition for
GetPathEnumerator «а метод расширенияGetPathEnumerator' of type
PathDefinition» может быть найдено (вы пропали без вести с помощью директивы или ссылка на сборку?)
Откуда у вас был тип PathDefinition? В документации Unity3D нет ни одного документа. В любом случае, это явно не содержит определения 'GetPathEnumerator' ... – walther
FWIW, этот код также был [отправлен 12 февраля на unity3d.com] (http: /answers.unity3d.com/questions/899757/can-someone-help-me-with-this-problem.html) без ответов. – cod3monk3y
@ cod3monk3y, да, я нашел его и в нескольких местах, никаких ответов. Это странно, потому что я не могу найти этот тип PathDefinition в любом месте, поэтому мне очень сложно понять, как мы должны отвечать на этот вопрос с таким количеством информации, предоставленной .. – walther