Unity Package Error "тип пространства имен не найден" - PullRequest
1 голос
/ 14 марта 2019

Привет, я использую пакет "Unity", который называется "Movement Animset Pro v1.693.unitypackage", для перемещения символа "Юнит", когда я импортирую пакет в "Юнит", все работает нормально, за исключением файла сценария, который дает мне ошибки во всем коде.используя последнюю версию Unity, и вот код

// (c) Copyright HutongGames, LLC 2010-2011.Все права защищены.

    using UnityEngine;

    namespace HutongGames.PlayMaker.Actions
    {


[ActionCategory(ActionCategory.Transform)]
[Tooltip("Moves a Game Object towards a Target. Optionally sends an event when successful. Optionally set when to update, during regular update, lateUpdate or FixedUpdate. The Target can be specified as a Game Object or a world Position. If you specify both, then the Position is used as a local offset from the Object's Position.")]
public class MoveTowards2 : FsmStateAction
{
    public enum UpdateType {Update,LateUpdate,FixedUpdate};

    [RequiredField]
    public FsmOwnerDefault gameObject;

    public FsmGameObject targetObject;

    public FsmVector3 targetPosition;

    public FsmBool ignoreVertical;

    [HasFloatSlider(0, 20)]
    public FsmFloat maxSpeed;

    [HasFloatSlider(0, 5)]
    public FsmFloat finishDistance;

    public FsmEvent finishEvent;

    public UpdateType updateType;


    public override void Reset()
    {
        gameObject = null;
        targetObject = null;
        maxSpeed = 10f;
        finishDistance = 1f;
        finishEvent = null;
        updateType = UpdateType.Update;
    }

    public override void OnUpdate()
    {
        if (updateType == UpdateType.Update)
        {
            DoMoveTowards();
        }
    }

    public override void OnLateUpdate()
    {
        if (updateType == UpdateType.LateUpdate)
        {
            DoMoveTowards();
        }
    }

    public override void OnFixedUpdate()
    {
        //if (updateType == UpdateType.FixedUpdate)
        //{
            DoMoveTowards();
        //}
    }

    void DoMoveTowards()
    {
        var go = Fsm.GetOwnerDefaultTarget(gameObject);
        if (go == null)
        {
            return;
        }

        var goTarget = targetObject.Value;
        if (goTarget == null && targetPosition.IsNone)
        {
            return;
        }

        Vector3 targetPos;
        if (goTarget != null)
        {
            targetPos = !targetPosition.IsNone ? 
                goTarget.transform.TransformPoint(targetPosition.Value) : 
                goTarget.transform.position;
        }
        else
        {
            targetPos = targetPosition.Value;
        }

        if (ignoreVertical.Value)
        {
            targetPos.y = go.transform.position.y;
        }

        go.transform.position = Vector3.MoveTowards(go.transform.position, targetPos, maxSpeed.Value * Time.deltaTime);

        var distance = (go.transform.position - targetPos).magnitude;
        if (distance < finishDistance.Value)
        {
            Fsm.Event(finishEvent);
            Finish();
        }
    }

}
}

и вот ошибки

Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(11,30): error CS0246: The type or namespace name 'FsmStateAction' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(9,3): error CS0246: The type or namespace name 'ActionCategoryAttribute' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(9,3): error CS0246: The type or namespace name 'ActionCategory' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(9,18): error CS0103: The name 'ActionCategory' does not exist in the current context
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(10,3): error CS0592: Attribute 'Tooltip' is not valid on this declaration type. It is only valid on 'field' declarations.
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(35,24): error CS0115: 'MoveTowards2.Reset()': no suitable method found to override
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(45,24): error CS0115: 'MoveTowards2.OnUpdate()': no suitable method found to override
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(53,24): error CS0115: 'MoveTowards2.OnLateUpdate()': no suitable method found to override
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(61,24): error CS0115: 'MoveTowards2.OnFixedUpdate()': no suitable method found to override
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(15,4): error CS0246: The type or namespace name 'RequiredFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(15,4): error CS0246: The type or namespace name 'RequiredField' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(16,10): error CS0246: The type or namespace name 'FsmOwnerDefault' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(18,10): error CS0246: The type or namespace name 'FsmGameObject' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(20,10): error CS0246: The type or namespace name 'FsmVector3' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(22,10): error CS0246: The type or namespace name 'FsmBool' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(24,4): error CS0246: The type or namespace name 'HasFloatSliderAttribute' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(24,4): error CS0246: The type or namespace name 'HasFloatSlider' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(25,10): error CS0246: The type or namespace name 'FsmFloat' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(27,4): error CS0246: The type or namespace name 'HasFloatSliderAttribute' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(27,4): error CS0246: The type or namespace name 'HasFloatSlider' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(28,10): error CS0246: The type or namespace name 'FsmFloat' could not be found (are you missing a using directive or an assembly reference?)
Assets\MovementAnimsetPro\PlayMakerAdditionalActions\PlayMaker\Actions\MoveTowards2.cs(30,10): error CS0246: The type or namespace name 'FsmEvent' could not be found (are you missing a using directive or an assembly reference?)

и есть 5 других скриптов с такими же ошибками .. помогите пожалуйста

1 Ответ

0 голосов
/ 14 марта 2019

Поскольку ошибка говорит о том, что программа не находит имена, такие как 'FsmStateAction', найдите в ваших ресурсах это имя и найдите скрипт, который его содержит, а затем поместите пространство имен скрипта вверху кода, например:

using someNamespace;

Я вижу, что у вас есть некоторые ошибки переопределения, вы не можете переопределить эти методы, если они не являются виртуальными, проверьте код пакета, прежде чем создавать свой собственный.

...