@sergMake

Выдает ошибку error: Type or namespace definition, or end-of-file expected?

Всех приветствую, у меня есть игра на Unity, и при попытке Build, мне выводит ошибку на один из скриптов. Я не понимаю что не так, в Unity все работает исправно, компилятор Visual Studio ошибок не выдает.
Assets\scripts\Turret\Turret.cs(134,1): error CS1022: Type or namespace definition, or end-of-file expected

using UnityEditor;
using UnityEngine;
using UnityEngine.UI;

public class Turret : MonoBehaviour
{ 
    
        public int healtTurret = 100;
        public float damagOnHealtBar;
        public static Turret S;
        public float _radiusTarget = 50f;
        [SerializeField] float _DistTarget;
        public Gun gun;


        public int HitDamag = 5;
        public MountPoint[] mountPoints;
        public Transform target;

        [SerializeField] bool targetNull;

        [SerializeField] GameObject smoke;

        [SerializeField] Image HealtBar;
        [SerializeField] Image healtBarBaground;

        [SerializeField] Outline lineObject;
        public void Start()
        {
            //damagOnHealtBar = healtTurret;
            S = this;
            smoke.SetActive(false);
            Distance();
        }
        void OnDrawGizmos()
        {
    #if UNITY_EDITOR
            if (!target) return;


            float dashLineSize = 2f;

            foreach (MountPoint mountPoint in mountPoints)
            {
                Transform hardpoint = mountPoint.transform;
                Vector3 from = Quaternion.AngleAxis(-mountPoint.angleLimit / 2, hardpoint.up) * hardpoint.forward;
                Vector3 projection = Vector3.ProjectOnPlane(target.position - hardpoint.position, hardpoint.up);

                // projection line
                Handles.color = Color.white;
                Handles.DrawDottedLine(target.position, hardpoint.position + projection, dashLineSize);

                // do not draw target indicator when out of angle
                if (Vector3.Angle(hardpoint.forward, projection) > mountPoint.angleLimit / 2) return;

                // target line
                Handles.color = Color.red;
                Handles.DrawLine(hardpoint.position, hardpoint.position + projection);

                // range line
                Handles.color = Color.green;
                Handles.DrawWireArc(hardpoint.position, hardpoint.up, from, mountPoint.angleLimit, projection.magnitude);
                Handles.DrawSolidDisc(hardpoint.position + projection, hardpoint.up, .5f);
    #endif
            }
        }

        public void Update()
        {


            // do nothing when no target
            if (!target) return;
            if (targetNull == true) return;


            // aim target
            bool aimed = true;
            if (_radiusTarget < _DistTarget) return;
            foreach (var mountPoint in mountPoints)
            {
                if (!mountPoint.Aim(target.position))
                {
                    aimed = false;
                }
            }

            // shoot when aimed
            if (aimed)
            {
                gun.Fire();
            }
            if (healtTurret <= 0)
            {

                target = null;
                lineObject.enabled = false;

                smoke.SetActive(true);
                //GetComponent<Turret>().enabled = false;
                FollowCam.S.NumTurret();
                return;
            }
            HealtBar.fillAmount = healtTurret / damagOnHealtBar;
            healtBarBaground.transform.rotation = Quaternion.LookRotation(transform.position - target.transform.position);



        }

        public void Distance()
        {

            Invoke(nameof(Distance), 0.5f);
            if (healtTurret <= 0)
            {
                HealtBar.fillAmount = 0f;
                return;
            }
            _DistTarget = Vector3.Distance(transform.position, target.position);
            if (_radiusTarget < _DistTarget)
            {
                targetNull = true;
            }
            else
            {
                targetNull = false;
            }


        }
}
  • Вопрос задан
  • 96 просмотров
Решения вопроса 1
Geminix
@Geminix
Фуллстек nuxt, .net разработчик
#endif в верном месте? Скобку следующую не захватывает.
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
@sergMake Автор вопроса
Я не знаю, там где #if и #endif это не моя часть кода, я его скопировал и переписал для себя. Посмотрите, пожалуйста вы.
Я сейчас закомментировал эту часть кода, в которой используется #endif (она для отрисовки), и все заработало. Но я не знаком с этими директивами, и не могу поставить их правильно.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы