コード例 #1
0
    private void OnEnable()
    {
        _gimmickBase = (GimmickBase)target;
        _manager     = _gimmickBase.GetComponentInParent <GimmickManager>();

        if (_manager)
        {
            _gimmicks = _manager.GetComponentsInChildren <GimmickBase>();
            _path     = _gimmickBase.GetComponentInParent <Bezier2D>();
        }

        _lineColor  = serializedObject.FindProperty("GimmickColor");
        _startPoint = serializedObject.FindProperty("StartPoint");
        _endPoint   = serializedObject.FindProperty("EndPoint");
    }
コード例 #2
0
    private static void DrawGizmos(GimmickBase gimmick, GizmoType gizmoType)
    {
        var manager = gimmick.GetComponentInParent <GimmickManager>();

        if (!manager)
        {
            return;
        }

        var path = manager.GetComponent <Bezier2D>();

        if (!path)
        {
            return;
        }
        if (path.LineCount <= 0)
        {
            return;
        }

        var startPoint = gimmick.StartPoint;
        var endPoint   = gimmick.EndPoint;

        if (startPoint > endPoint)
        {
            return;
        }

        //線を薄く表示
        var lineCount = path.LineCount;
        var partition = 32 * lineCount;

        var diff = endPoint - startPoint;
        var dt   = diff / partition;

        var points = new List <Vector3> {
            path.GetPoint(startPoint / lineCount)
        };

        for (var i = 1; i <= partition; i++)
        {
            points.Add(path.GetPoint((startPoint + dt * i) / lineCount));
        }

        Handles.color = gimmick.GimmickColor;
        Handles.DrawAAPolyLine(LineWidth, points.ToArray());
    }