Esempio n. 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]));
        }
Esempio n. 2
0
 protected internal override void Reset()
 {
     base.Reset();
     target           = null;
     targetClass      = null;
     accessor         = null;
     type             = -1;
     equation         = null;
     path             = null;
     isFrom           = isRelative = false;
     combinedAttrsCnt = waypointsCnt = 0;
     if (accessorBuffer.Length != combinedAttrsLimit)
     {
         accessorBuffer = new float[combinedAttrsLimit];
     }
     if (pathBuffer.Length != (2 + waypointsLimit) * combinedAttrsLimit)
     {
         pathBuffer = new float[(2 + waypointsLimit) * combinedAttrsLimit];
     }
 }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
    void OnEnable()
    {
        //i like bold handle labels since I'm getting old:
        style.fontStyle        = FontStyle.Bold;
        style.normal.textColor = Color.white;
        _target = (TweenPath)target;

        //lock in a default path name:
        if (!_target.initialized)
        {
            _target.initialized = true;
            _target.pathName    = "New Path " + ++count;
            _target.initialName = _target.pathName;
            Vector3 pos = _target.gameObject.transform.position;
            for (int i = 0; i < _target.nodes.Count; ++i)
            {
                _target.nodes[i] = pos +
                                   (new Vector3(Random.Range(-100, 100), Random.Range(-100, 100), Random.Range(-100, 100))).normalized * 5;
            }
        }
    }
Esempio n. 5
0
 /// <summary>
 /// Sets the algorithm that will be used to navigate through the waypoints,
 /// from the start values to the end values.
 /// </summary>
 /// <remarks>
 /// Sets the algorithm that will be used to navigate through the waypoints,
 /// from the start values to the end values. Default is a catmull-rom spline,
 /// but you can find other paths in the
 /// <see cref="TweenPaths">TweenPaths</see>
 /// class.
 /// </remarks>
 /// <param name="path">A TweenPath implementation.</param>
 /// <returns>The current tween, for chaining instructions.</returns>
 /// <seealso cref="TweenPath">TweenPath</seealso>
 /// <seealso cref="TweenPaths">TweenPaths</seealso>
 public Tween Path(TweenPath path)
 {
     this.path = path;
     return(this);
 }
Esempio n. 6
0
 public static TweenerCore <Vector3, Path, PathOptions> DOLocalPath(this TweenPath path, float duration, PathType pathType = PathType.Linear, PathMode pathMode = PathMode.Full3D, int resolution = 10, Color?gizmoColor = null)
 {
     return(DOLocalPath(path.transform, path.nodes.ToArray(), duration, pathType, pathMode, resolution, gizmoColor));
 }