Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        m_bezier    = gameObject.GetComponent <MUIBezierValue>();
        bezierValue = 0;
        mDelta      = 0;
        for (int i = 0; i < transform.childCount; i++)
        {
            Transform trans = transform.GetChild(i);
            Vector2   pos   = m_bezier.GetBezierValue(.25f * i);
            trans.position      = pos;
            pos                 = trans.localPosition;
            trans.localPosition = new Vector3(-500, 0, 0);
            float   duration   = 0f;
            Vector3 scaleValue = Vector3.one;
            duration   = itemDuration[i];
            scaleValue = Vector3.one * itemScale[i];

            TweenPosition posTween = TweenPosition.Begin(trans.gameObject, duration, pos);
            posTween.animationCurve = posCurve;
            TweenScale scaleTween = TweenScale.Begin(trans.gameObject, duration, scaleValue);
            scaleTween.animationCurve = scaleCurve;
            if (i == 0)
            {
                EventDelegate.Add(scaleTween.onFinished, OnStartTweenFinish, true);
            }
        }
    }
Ejemplo n.º 2
0
    void OnSceneGUI()
    {
        mBezierValue = (MUIBezierValue)target;

        if (mBezierValue == null)
        {
            return;
        }

        scaleFactor = RootScale(mBezierValue.transform.parent);
        //if (scaleFactor.Equals(Vector3.zero))
        //{
        //    Debug.Log(scaleFactor);
        //}
        mBezierValue.bezierPoints.Clear();
        foreach (MUIBezierPoint point in mBezierValue.gameObject.GetComponents <MUIBezierPoint>())
        {
            mBezierValue.bezierPoints.Add(point);
        }
        mBezierPoints = mBezierValue.bezierPoints;

        if (mBezierValue.enabled)
        {
            if (mBezierPoints.Count < 2)
            {
                return;
            }

            for (int i = 0; i < mBezierPoints.Count; i++)
            {
                if (i < mBezierPoints.Count - 1)
                {
                    Vector2 controlPoint = mBezierPoints[i].controlPoint;
                    if (i > 0)
                    {
                        controlPoint = SymmetryPoint(mBezierPoints[i].controlPoint, mBezierPoints[i].positionPoint);
                    }
                    Handles.DrawBezier(mBezierPoints[i].positionPoint, mBezierPoints[i + 1].positionPoint, controlPoint, mBezierPoints[i + 1].controlPoint, Color.green, null, 2);
                }
                Handles.color = Color.white;
                Handles.ConeCap(i, mBezierPoints[i].positionPoint, Quaternion.identity, .05f);

                Vector2 currentPoint = mBezierPoints[i].controlPoint;
                currentPoint  = Handles.PositionHandle(currentPoint, Quaternion.identity);
                Handles.color = Color.red;
                Handles.ConeCap(i, currentPoint, Quaternion.identity, .05f);
                Handles.color = Color.white;
                Handles.Label(currentPoint, "control point" + i);
                mBezierPoints[i].controlPoint = currentPoint;

                Handles.color = Color.magenta;
                Handles.DrawLine(mBezierPoints[i].controlPoint, mBezierPoints[i].positionPoint);

                Vector2 positionPoint = mBezierPoints[i].positionPoint;
                positionPoint = Handles.PositionHandle(positionPoint, Quaternion.identity);
                Handles.color = Color.white;
                Handles.Label(positionPoint, "point" + i);
                mBezierPoints[i].positionPoint = positionPoint;

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(mBezierValue);
                }
            }
        }
    }