Example #1
0
        private void OnEnable()
        {
            tweenPath = target as TweenPath;
            if (tweenPath.LocalNodes == null)
            {
                tweenPath.LocalNodes = new List <Vector3>();
            }
            gs = new GUIStyle();
            gs.normal.textColor = gs.hover.textColor = gs.focused.textColor = Color.white;
            gs.fontSize         = 12;
            gs.alignment        = TextAnchor.MiddleCenter;
            Init();
            EditorApplication.update += SimulationUpdate;
//            var assets = AssetDatabase.FindAssets("BezierCurveFont t:font");
//            if (assets.Length > 0)
//                monoFont = AssetDatabase.LoadAssetAtPath<Font>(AssetDatabase.GUIDToAssetPath(assets[0]));
        }
Example #2
0
        private void DrawNodes(TweenPath tnPath, Matrix4x4 mtx)
        {
            Handles.color = tnPath.DebugColor;
            var inverseMtx     = mtx.inverse;
            var handleRotation = tnPath.ApplyRootTransform ? tnPath.transform.rotation : Quaternion.identity;

//            List<Vector3> Nodes = tnPath.Nodes;
            for (var i = 0; i < tnPath.LocalNodes.Count; i++)
            {
//                var item = tnPath.Nodes[i];
                if (i == list.index || editMode == emEditMode.ALL)
                {
                    Vector4 origin   = mtx * ToVec4(tnPath.LocalNodes[i]);
                    Vector3 oldOrign = origin;
                    var     nOrigin  = Handles.DoPositionHandle(origin, handleRotation); // 绘制节点。
                    nOrigin = ConstraintAxis(nOrigin, oldOrign);
                    if (nOrigin != oldOrign)
                    {
                        Undo.RecordObject(tnPath, "node changing origin");
                        Vector3 delta = inverseMtx * (nOrigin - oldOrign);
                        if (editMode == emEditMode.Root)
                        {
                            for (var j = 0; j < tnPath.LocalNodes.Count; j++)
                            {
                                tnPath.LocalNodes[j] += delta;
                            }
                        }
                        else
                        {
                            tnPath.LocalNodes[i] += delta;
                        }
                    }
                }
                else
                {
                    var nodePos = mtx * ToVec4(tnPath.LocalNodes[i]);
                    Handles.color = tnPath.DebugColor;
                    Handles.CubeCap(0, nodePos, handleRotation, HandleUtility.GetHandleSize(nodePos) * .1f);
                }
            }
        }