Пример #1
0
        public static void GizmosDrawLineInterpolated(LineBase source, LineRendererBase renderer)
        {
            Vector3 firstPos = source.GetPoint(0f);
            Vector3 lastPos  = firstPos;
            Color   gColor   = renderer.GetColor(0);

            gColor.a     = 0.5f;
            Gizmos.color = gColor;
            Gizmos.DrawSphere(firstPos, renderer.GetWidth(0) / 2);
            for (int i = 1; i <= renderer.NumLineSteps; i++)
            {
                float   normalizedLength = (1f / (renderer.NumLineSteps)) * i;
                Vector3 currentPos       = source.GetPoint(normalizedLength);
                gColor       = renderer.GetColor(normalizedLength);
                gColor.a     = gColor.a * 0.5f;
                Gizmos.color = gColor;
                Gizmos.DrawLine(lastPos, currentPos);
                Gizmos.DrawSphere(currentPos, renderer.GetWidth(normalizedLength) / 2);
                lastPos = currentPos;
            }

            if (source.Loops)
            {
                Gizmos.DrawLine(lastPos, firstPos);
            }
        }
Пример #2
0
            protected override void DrawCustomSceneGUI()
            {
                base.DrawCustomSceneGUI();

                LineBase line = (LineBase)target;

                line.FirstPoint = SquareMoveHandle(line.FirstPoint);
                line.LastPoint  = SquareMoveHandle(line.LastPoint);
            }
Пример #3
0
        public static void GizmosDrawLineRenderer(LineBase source, LineRendererBase renderer)
        {
            switch (renderer.StepMode)
            {
            case StepModeEnum.FromSource:
                GizmosDrawLineFromSource(source, renderer);
                break;

            case StepModeEnum.Interpolated:
                GizmosDrawLineInterpolated(source, renderer);
                break;
            }
        }
Пример #4
0
        protected virtual void OnDrawGizmos()
        {
            if (Application.isPlaying)
            {
                return;
            }

            if (source == null)
            {
                source = gameObject.GetComponent <LineBase>();
            }
            if (source == null || !source.enabled)
            {
                return;
            }

            GizmosDrawLineRenderer(source, this);
        }