//uses WaypointSettings to get the default back and set them.
 private void InitDefaultValueFromScriptable()
 {
     _defaultStickMode       = WaypointSettings.GetInstance().DefaultStickMode;
     _loopType               = WaypointSettings.GetInstance().DefaultLoopType;
     _waypointsColor         = WaypointSettings.GetInstance().WaypointsColor;
     _defaultDistanceToReach = WaypointSettings.GetInstance().DefaultDistanceToReach;
     StartAtTheNearest       = WaypointSettings.GetInstance().StartAtTheNearest;
 }
        public static WaypointSettings GetInstance()
        {
            if (!_instance)
            {
                try
                {
                    //gets the Scriptable object instance asset in the Assets folder.
                    _instance = Resources.LoadAll <WaypointSettings>("").First();
                }
                catch (Exception)
                {
                    Debug.LogError("No WaypointSettings !");
                }
            }

            return(_instance);
        }
Exemplo n.º 3
0
        private void OnDrawGizmos()
        {
            if (_system == null)
            {
                _system = transform.parent.GetComponent <WaypointSystem>();
            }

            Gizmos.color = _system.WaypointsColor;
            Gizmos.DrawSphere(this.transform.position, 0.4f);
            if (WaypointSettings.GetInstance().ShowTheDistanceToReachFGizmos)
            {
                Gizmos.DrawWireSphere(this.transform.position, this.DistanceToReach);
            }

            if (this.NextWaypoint != null)
            {
                var position = this.transform.position;
                var nextPos  = this.NextWaypoint.transform.position;
                var dir      = (nextPos - position);

                Gizmos.color = Color.white;
                Gizmos.DrawLine(position, nextPos);
                Gizmos.DrawWireMesh(Resources.Load <MeshFilter>("direction_arrow").sharedMesh,
                                    (nextPos + position) / 2,
                                    (dir == Vector3.zero)
                        ? Quaternion.identity
                        : Quaternion.LookRotation(dir).normalized, Vector3.one / 3);

                if (_system.LoopType == LoopType.PingPong)
                {
                    Gizmos.DrawWireMesh(Resources.Load <MeshFilter>("direction_arrow").sharedMesh,
                                        (nextPos + position) / 2,
                                        (dir == Vector3.zero)
                            ? Quaternion.identity
                            : Quaternion.LookRotation(dir * -1).normalized, Vector3.one / 3);
                }
            }
        }