Example #1
0
        public override void OnInspectorGUI()
        {
            GUI.DrawTexture(new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon());

            LeanTweenVisual tween = target as LeanTweenVisual;

            EditorGUI.BeginChangeCheck();
            float   overallDelay = 0;
            bool    clicked, deleted;
            Vector3 vec;

            clicked = false;

            tween.playOnStart = EditorGUILayout.Toggle(new GUIContent("Play on Start", "Tweens won't start automatically, you can start them via code with .start()"), tween.playOnStart, GUILayout.Width(100));
            EditorGUILayout.BeginHorizontal();

            tween.restartOnEnable = EditorGUILayout.Toggle(new GUIContent("Restart on enable", "When you enable the gameobject these set of tweens will start again"), tween.restartOnEnable);
            tween.repeat          = EditorGUILayout.Toggle(new GUIContent("Repeat All", "Repeat the whole set of tween groups once they finish"), tween.repeat);
            EditorGUILayout.EndHorizontal();
            if (tween.repeat)
            {
                tween.repeatDelay = EditorGUILayout.FloatField("All Delay", tween.repeatDelay);
                tween.repeatCount = EditorGUILayout.IntField("All Repeat Count", tween.repeatCount);
            }

            float addedGroupDelay = 0f;

            foreach (LeanTweenGroup group in tween.groupList)
            {
                EditorGUILayout.Space();

                GUI.color = LTEditor.shared.colorGroupName;
                EditorGUILayout.BeginHorizontal();

                group.foldout = EditorGUILayout.Foldout(group.foldout, "", LTEditor.shared.styleGroupFoldout);
                clicked       = GUILayout.Button("Group: " + group.name + " " + (group.startTime) + "s - " + (group.endTime) + "s", LTEditor.shared.styleGroupButton);
                GUI.color     = LTEditor.shared.colorDelete;
                deleted       = GUILayout.Button("Delete", LTEditor.shared.styleDeleteGroupButton);
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;

                if (clicked)
                {
                    group.foldout = !group.foldout;
                }
                if (deleted)
                {
                    Undo.RecordObject(tween, "Removing group item");
                    tween.groupList.Remove(group);
                    break;
                }

                float addedTweenDelay = 0f;
                if (group.foldout)
                {
                    group.name = EditorGUILayout.TextField("Group Name", group.name);
                    EditorGUILayout.BeginHorizontal();
                    group.repeat = EditorGUILayout.Toggle("Group Repeat", group.repeat);
                    group.delay  = EditorGUILayout.FloatField("Group Delay", group.delay);
                    EditorGUILayout.EndHorizontal();

                    group.gameObject = EditorGUILayout.ObjectField("Group GameObject", group.gameObject, typeof(GameObject), true) as GameObject;
                    if (group.gameObject == null)                   // Should default to the current object
                    {
                        group.gameObject = tween.gameObject;
                    }
                    if (group.repeat)
                    {
                        group.repeatCount = EditorGUILayout.IntField("Group Repeat Count", group.repeatCount);
                    }

                    int i = 0;
                    foreach (LeanTweenItem item in group.itemList)
                    {
                        TweenAction a = (TweenAction)item.action;

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(15);

                        item.foldout = EditorGUILayout.Foldout(item.foldout, "Tween ");
                        GUI.color    = LTEditor.shared.colorTweenName;

                        int actionIndex = EditorGUILayout.Popup(LTVisualShared.actionIndex(item), LTVisualShared.methodLabels);

                        LTVisualShared.setActionIndex(item, actionIndex);

                        // clicked = GUILayout.Button(""+a + " " + ( group.delay + item.delay) + "s - " + ( group.delay + item.delay + item.duration) + "s");
                        GUI.color = LTEditor.shared.colorDelete;
                        deleted   = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton);
                        EditorGUILayout.EndHorizontal();
                        GUI.color = Color.white;


                        if (clicked)
                        {
                            item.foldout = !item.foldout;
                        }
                        if (deleted)
                        {
                            Undo.RecordObject(tween, "Removing tween item");
                            group.itemList.Remove(item);

                            break;
                        }

                        if (item.foldout)
                        {
                            a = item.action;
                            bool tweenTypeChanged = (int)item.action != item.actionLast;
                            if (tweenTypeChanged && item.actionLast >= 0)
                            {
                                // Setup with the helpful default values
                                // Debug.Log("Setting up to default values a:"+a);

                                /*item.to = Vector3.zero;
                                 * if((a>=TweenAction.MOVE_X && a<=TweenAction.MOVE_LOCAL_Z) || a==TweenAction.MOVE || a==TweenAction.MOVE_LOCAL)
                                 *      item.to = item.from = tween.gameObject.transform.position;
                                 * else if((a>=TweenAction.SCALE_X && a<=TweenAction.SCALE_Z) || a==TweenAction.SCALE)
                                 *      item.to = item.from = tween.gameObject.transform.localScale;
                                 #if !UNITY_4_3 && !UNITY_4_5
                                 * else if(a==TweenAction.CANVAS_MOVE)
                                 *      item.to = item.from = tween.gameObject.GetComponent<RectTransform>().anchoredPosition;
                                 * else if(a==TweenAction.CANVAS_SCALE)
                                 *      item.to = item.from = tween.gameObject.GetComponent<RectTransform>().localScale;
                                 #endif
                                 */
                            }
                            item.actionLast = (int)item.action;
                            // Debug.Log("a:"+a);

                            item.gameObject = EditorGUILayout.ObjectField("    GameObject", item.gameObject, typeof(GameObject), true, GUILayout.Width(250)) as GameObject;
                            if (item.gameObject == null)                           // Should default to the current object
                            {
                                item.gameObject = tween.gameObject;
                            }

                            // Path
                            bool isCurve = false;
                            if (a == TweenAction.MOVE_CURVED || a == TweenAction.MOVE_CURVED_LOCAL)
                            {
                                item.bezierPath = EditorGUILayout.ObjectField("    LeanTweenPath:", item.bezierPath, typeof(LeanTweenPath), true) as LeanTweenPath;

                                EditorGUILayout.BeginHorizontal();
                                change(ref item.orientToPath, EditorGUILayout.Toggle("    Orient to Path", item.orientToPath), tween, "Orient to path");
//								if(orientToPath!=item.orientToPath){
//									Undo.RecordObject(tween,"Orient to path");
//									item.orientToPath = orientToPath;
//								}
                                isCurve = true;

                                item.isPath2d = EditorGUILayout.Toggle("    2D Path", item.isPath2d);
                                EditorGUILayout.EndHorizontal();
                            }
                            else if (a == TweenAction.MOVE_SPLINE || a == TweenAction.MOVE_SPLINE_LOCAL)
                            {
                                item.splinePath   = EditorGUILayout.ObjectField("    LeanTweenPath:", item.splinePath, typeof(LeanTweenPath), true) as LeanTweenPath;
                                item.orientToPath = EditorGUILayout.Toggle("    Orient to Path", item.orientToPath);
                                isCurve           = true;
                            }

                            if (isCurve == false)
                            {
                                bool isVector = a == TweenAction.MOVE || a == TweenAction.MOVE_LOCAL || a == TweenAction.CANVAS_MOVE || a == TweenAction.ROTATE || a == TweenAction.ROTATE_LOCAL || a == TweenAction.SCALE || a == TweenAction.CANVAS_SCALE || a == TweenAction.CANVAS_SIZEDELTA || a == TweenAction.DELAYED_SOUND;
                                bool isColor  = a >= TweenAction.COLOR && a < TweenAction.CALLBACK;
                                bool isPlay   = a == TweenAction.CANVAS_PLAYSPRITE;
                                bool usesFrom = !isColor && !isPlay;

                                // From Values
                                EditorGUILayout.BeginHorizontal();
                                if (usesFrom)                                 // Not a Color tween
                                {
                                    EditorGUILayout.LabelField(new GUIContent("    From", "Specify where the tween starts from, otherwise it will start from it's current value"), GUILayout.Width(50));
                                    LeanTweenBetween between = EditorGUILayout.Toggle("", item.between == LeanTweenBetween.FromTo, GUILayout.Width(30)) ? LeanTweenBetween.FromTo : LeanTweenBetween.To;
                                    if (between != item.between)
                                    {
                                        Undo.RecordObject(tween, "Changing to from/to");
                                        item.between = between;
                                    }
                                }
                                if (item.between == LeanTweenBetween.FromTo)
                                {
                                    if (isVector)
                                    {
//										item.from = EditorGUILayout.Vector3Field("", item.from);
                                        change(ref item.from, EditorGUILayout.Vector3Field("", item.from), tween, "Changing from");
                                    }
                                    else if (isColor)
                                    {
                                    }
                                    else
                                    {
                                        vec   = Vector3.zero;
                                        vec.x = EditorGUILayout.FloatField("From", item.from.x);
                                        if (vec.x != item.from.x)
                                        {
                                            Undo.RecordObject(tween, "Setting new from value");
                                            item.from = vec;
                                        }
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                // To Values
                                EditorGUILayout.BeginHorizontal();
                                if (isVector)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    change(ref item.to, EditorGUILayout.Vector3Field("", item.to), tween, "Changing vector3 to");
                                }
                                else if (isColor)
                                {
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    change(ref item.colorTo, EditorGUILayout.ColorField("", item.colorTo), tween, "Change color to");
                                }
                                else if (isPlay)
                                {
                                    GUILayout.Space(24);
                                    item.spritesMaximized = EditorGUILayout.Foldout(item.spritesMaximized, "Sprites");
                                    if (item.spritesMaximized)
                                    {
                                        EditorGUILayout.LabelField("Add", GUILayout.Width(35));
                                        UnityEngine.Sprite sprite = EditorGUILayout.ObjectField("", null, typeof(UnityEngine.Sprite), true, GUILayout.Width(150)) as UnityEngine.Sprite;
                                        if (sprite != null)
                                        {
                                            Undo.RecordObject(tween, "Adding a sprite");
                                            item.sprites = add(item.sprites, sprite);
                                        }
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                        EditorGUILayout.Separator();
                                    }
                                }
                                else
                                {
                                    vec = Vector3.zero;
                                    EditorGUILayout.LabelField("    To", GUILayout.Width(85));
                                    float setToX = EditorGUILayout.FloatField("", item.to.x);
                                    if (setToX != vec.x)
                                    {
                                        Undo.RecordObject(tween, "Setting x to");
                                        vec.x   = setToX;
                                        item.to = vec;
                                    }
                                }
                                EditorGUILayout.EndHorizontal();

                                // Sprite List
                                if (isPlay && item.spritesMaximized)
                                {
                                    for (int j = 0; j < item.sprites.Length; j++)
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        EditorGUILayout.LabelField("        sprite" + j, GUILayout.Width(85));
                                        item.sprites[j] = EditorGUILayout.ObjectField("", item.sprites[j], typeof(UnityEngine.Sprite), true) as UnityEngine.Sprite;
                                        GUI.color       = LTEditor.shared.colorDelete;
                                        deleted         = GUILayout.Button("Delete", LTEditor.shared.styleDeleteButton);
                                        GUI.color       = Color.white;
                                        EditorGUILayout.EndHorizontal();

                                        if (deleted)
                                        {
                                            Undo.RecordObject(tween, "Removing sprite");
                                            item.sprites = remove(item.sprites, j);
                                            break;
                                        }
                                    }
                                }

                                if (a == TweenAction.ROTATE_AROUND || a == TweenAction.ROTATE_AROUND_LOCAL
                                                                #if !UNITY_4_3 && !UNITY_4_5
                                    || a == TweenAction.CANVAS_ROTATEAROUND || a == TweenAction.CANVAS_ROTATEAROUND_LOCAL
                                                                #endif
                                    )
                                {
                                    item.axis = ShowAxis("    Axis", item.axis);
                                }
                            }
                            EditorGUILayout.Space();

                            // Easing
                            if (a == TweenAction.DELAYED_SOUND)
                            {
                                change(ref item.audioClip, EditorGUILayout.ObjectField("    AudioClip:", item.audioClip, typeof(AudioClip), true) as AudioClip, tween, "set audio clip");
                            }
                            else
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField("    Easing", GUILayout.Width(80));

                                int easeIndex    = LTVisualShared.easeIndex(item);
                                int easeIndexNew = EditorGUILayout.Popup("", easeIndex, LTVisualShared.easeStrMapping, GUILayout.Width(128));
                                if (easeIndex != easeIndexNew)
                                {
                                    Undo.RecordObject(tween, "changing easing type");
                                    LTVisualShared.setEaseIndex(item, easeIndexNew);
                                }

                                EditorGUILayout.Separator();
                                EditorGUILayout.EndHorizontal();

                                if (item.ease == LeanTweenType.animationCurve)
                                {
                                    Undo.RecordObject(tween, "changing easing type anim curve");
                                    item.animationCurve = EditorGUILayout.CurveField("    Ease Curve", item.animationCurve);
                                }
                                EditorGUILayout.Space();
                            }
                            if (item.ease >= LeanTweenType.once && item.ease < LeanTweenType.animationCurve)
                            {
                                EditorGUILayout.LabelField(new GUIContent("   ERROR: You Specified a non-easing type", "Select a type with the value 'Ease' in front of it (or linear)"), EditorStyles.boldLabel);
                            }

                            // Speed

                            EditorGUILayout.BeginHorizontal();
                            change(ref item.useSpeed, EditorGUILayout.Toggle("    Use Speed", item.useSpeed), tween, "toggled use speed");
                            EditorGUILayout.EndHorizontal();

                            // Timing
                            if (i > 0)
                            {
                                change(ref item.alignWithPrevious, EditorGUILayout.Toggle(new GUIContent("    Align with Previous", "When you change the timing of a previous tween, this tween's timing will be adjusted to follow afterwards."), item.alignWithPrevious),
                                       tween, "toggle align with previous");
                            }
                            EditorGUILayout.BeginHorizontal();
                            if (i > 0 && item.alignWithPrevious)
                            {
                                change(ref item.delay, addedTweenDelay, tween, "change delay");
                                EditorGUILayout.LabelField("    Delay:   " + item.delay, GUILayout.Width(50));
                            }
                            else
                            {
                                EditorGUILayout.LabelField("    Delay", GUILayout.Width(50));
                                change(ref item.delay, EditorGUILayout.FloatField("", item.delay, GUILayout.Width(50)), tween, "change delay");
                            }

                            if (a == TweenAction.DELAYED_SOUND)
                            {
                                EditorGUILayout.LabelField("Volume", GUILayout.Width(50));
                                change(ref item.duration, EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50)), tween, "change volume");
                            }
                            else if (a == TweenAction.CANVAS_PLAYSPRITE)
                            {
                                EditorGUILayout.LabelField("Frame Rate", GUILayout.Width(85));
                                change(ref item.frameRate, EditorGUILayout.FloatField("", item.frameRate, GUILayout.Width(50)), tween, "change volume");
                            }
                            else if (item.useSpeed)
                            {
                                EditorGUILayout.LabelField("Speed", GUILayout.Width(50));
                                change(ref item.speed, EditorGUILayout.FloatField("", item.speed, GUILayout.Width(50)), tween, "change speed");
                            }
                            else
                            {
                                EditorGUILayout.LabelField("Time", GUILayout.Width(50));
                                float newDuration = EditorGUILayout.FloatField("", item.duration, GUILayout.Width(50));
                                if (newDuration <= 0.0f)
                                {
                                    newDuration = 0.0001f;
                                }
                                change(ref item.duration, newDuration, tween, "change timing");
                            }
                            EditorGUILayout.Separator();
                            EditorGUILayout.EndHorizontal();



                            // Repeat
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("    Loops", GUILayout.Width(50));
                            change(ref item.doesLoop, EditorGUILayout.Toggle("", item.doesLoop, GUILayout.Width(50)), tween, "toggled does loop");

                            if (item.doesLoop)
                            {
                                EditorGUILayout.LabelField(new GUIContent("Repeat", "-1 repeats infinitely"), GUILayout.Width(50));
                                change(ref item.loopCount, EditorGUILayout.IntField(new GUIContent("", ""), item.loopCount, GUILayout.Width(50)), tween, "changed loop count");
                                EditorGUILayout.LabelField(new GUIContent("    Wrap", "How the tween repeats\nclamp: restart from beginning\npingpong: goes back and forth"), GUILayout.Width(50));
                                int index = item.loopType == LeanTweenType.pingPong ? 1 : 0;
                                index = EditorGUILayout.Popup("", index, new string[] { "Clamp", "Ping Pong" }, GUILayout.Width(70));
                                LeanTweenType newLoopType = index == 0 ? LeanTweenType.clamp : LeanTweenType.pingPong;
                                if (newLoopType != item.loopType)
                                {
                                    Undo.RecordObject(tween, "change loop type");
                                    item.loopType = newLoopType;
                                }
                            }
                            EditorGUILayout.EndHorizontal();

                            addedTweenDelay = item.duration + item.delay;

                            EditorGUILayout.Separator();
                            EditorGUILayout.Separator();

                            i++;
                        }
                    }
                    if (ShowLeftButton("+ Tween", LTEditor.shared.colorAddTween, 15))
                    {
                        Undo.RecordObject(tween, "adding another tween");
                        LeanTweenItem newItem = new LeanTweenItem(addedTweenDelay);
                        newItem.alignWithPrevious = true;
                        group.itemList.Add(newItem);
                    }
                    addedGroupDelay += addedTweenDelay;

                    EditorGUILayout.Separator();
                }
                overallDelay += group.endTime;
            }

            if (ShowLeftButton("+ Group", LTEditor.shared.colorAddGroup))
            {
                Undo.RecordObject(tween, "adding another group");
                // Debug.Log("adding group with delay:"+addedGroupDelay);
                tween.groupList.Add(new LeanTweenGroup(addedGroupDelay));
            }


            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Generated C# Code", EditorStyles.boldLabel);
            if (Application.isPlaying == false)
            {
                scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height(150));

                EditorGUILayout.TextArea(tween.buildAllTweens(true), LTEditor.shared.styleCodeTextArea);

                EditorGUILayout.EndScrollView();
            }
            else
            {
                EditorGUILayout.LabelField("    Not available during runtime");
            }

            if (EditorGUI.EndChangeCheck())
            {
//				Debug.Log("Saving time:"+Time.time);
                //Undo.RecordObject(tween, "LeanTweenVisual change");
            }
        }
Example #2
0
 public void OnEnable()
 {
     LTVisualShared.updateTweens(target as LeanTweenVisual);
 }
Example #3
0
 private void Awake()
 {
     LTVisualShared.updateTweens(this);
 }
Example #4
0
        public static void updateTweens(LeanTweenVisual tween)
        {
            //LeanTweenVisual tween = target as LeanTweenVisual;

            // Debug.Log("tween.versionNum:"+tween.versionNum);
            if (tween.versionNum == 0)           // upgrade script from 2.12
            {
                foreach (LeanTweenGroup group in tween.groupList)
                {
                    foreach (LeanTweenItem item in group.itemList)
                    {
                        // search through old lookup table for enums to convert over item.action to new string based saved format
                        Debug.Log("to action:" + (int)item.action);
                        if ((int)item.action < LT_2_12_MethodNames.Length - 1)
                        {
                            item.actionStr = LT_2_12_MethodNames[(int)item.action];
                        }
                        else
                        {
                            item.actionStr = LT_2_12_MethodNames[LT_2_12_MethodNames.Length - 1];
                        }

                        Debug.Log("item.action toStr:" + item.actionStr);
                    }
                }
                tween.versionNum = 220;
            }
            else
            {
                tween.versionNum = 220;
            }
            string editType = "0";

                        #if !UNITY_4_3 && !UNITY_4_5
            if (tween.gameObject.GetComponent <RectTransform>())
            {
                editType = "1";
                //Debug.Log("tween :"+tween+" is RectTransform");
            }
            else
            {
                //Debug.Log("tween :"+tween+" is Transform");
            }
                        #endif

            // Debug.Log("OnEnable methodLabels:"+methodLabels);
            //if(methodLabels==null){
            int labelsCount = 0;
            for (int i = 0; i < methodLabelsGrouping.Length; i++)
            {
                for (int k = 0; k < methodLabelsGrouping[i].Length; k++)
                {
                    if (methodLabelsGrouping[i][k].Equals(editType))
                    {
                        labelsCount++;
                    }
                }
            }

            methodLabels     = new string[labelsCount];
            methodStrMapping = new string[labelsCount];
            methodIntMapping = new int[labelsCount];
            int inputIter = 0;
            for (int i = 0; i < methodLabelsGrouping.Length; i++)
            {
                for (int k = 0; k < methodLabelsGrouping[i].Length; k++)
                {
                    if (methodLabelsGrouping[i][k].Equals(editType))
                    {
                        methodLabels[inputIter]     = (string)methodLabelsGrouping[i][0];
                        methodStrMapping[inputIter] = methodStrMappingGrouping[i];
                        methodIntMapping[inputIter] = methodIntMappingGrouping[i];
                        inputIter++;
                    }
                }
            }
            //}

            foreach (LeanTweenGroup group in tween.groupList)
            {
                foreach (LeanTweenItem item in group.itemList)
                {
                    int actionIndex = LTVisualShared.actionIndex(item);
                    item.action    = (TweenAction)methodIntMapping[actionIndex];
                    item.actionStr = methodStrMapping[actionIndex];
                }
            }
        }
        //private float optionsControlSize = 1.0f;

        public override void OnInspectorGUI()
        {
            LeanTweenPath path = target as LeanTweenPath;

            pos = path.transform.position;

            GUI.DrawTexture(new Rect(16, EditorGUILayout.GetControlRect().y - 16, 16, 16), LTEditor.editorIcon());

            EditorGUIUtility.labelWidth = 90f;

            EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            LeanTweenPath.LeanTweenPathType pathTypeLast = path.pathType;
            GUI.color     = LTEditor.shared.colorRefresh;
            path.pathType = (LeanTweenPath.LeanTweenPathType)EditorGUILayout.EnumPopup("Path Type", path.pathType);
            if (path.pathType != pathTypeLast)
            {
                Undo.RecordObject(path, "changing path type");
                resetPath();
            }
            bool isBezier = path.pathType == LeanTweenPath.LeanTweenPathType.bezier;

            EditorGUILayout.Space();
            float controlSizeBefore = path.controlSize;

            GUI.color = Color.white;
            LTVisualShared.change(ref path.controlSize, EditorGUILayout.FloatField("Controls Size", path.controlSize, GUILayout.Width(120)), path, "changing control size");
            if (path.controlSize != controlSizeBefore)
            {
                SceneView.RepaintAll();
            }

            EditorGUILayout.EndHorizontal();
            LTVisualShared.change(ref path.showArrows, EditorGUILayout.Toggle("Show Arrows", path.showArrows), path, "changing show arrows");

            EditorGUILayout.Space();

            GUI.color = LTEditor.shared.colorRefresh;
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Reverse Direction", LTEditor.shared.styleActionButton))
            {
                Undo.RecordObject(path, "reversing direction");
                Vector3[] newPath = new Vector3[path.pts.Length];
                for (int i = 0; i < newPath.Length; i++)
                {
                    // Debug.Log("pt at:"+(newPath.Length-i-1)+ " len:"+newPath.Length);
                    Transform trans = path.pts[newPath.Length - i - 1];
                    if (trans == null)
                    {
                        trans = path.pts[newPath.Length - i - 2];
                    }
                    newPath[i] = trans.position;
                }

                for (int i = 0; i < path.pts.Length; i++)
                {
                    if (path.pts[i])
                    {
                        path.pts[i].position = newPath[i];
                    }
                }
            }
            if (isBezier && GUILayout.Button("Easy Path Creator", LTEditor.shared.styleActionButton))
            {
                Undo.RecordObject(path, "expanding");
                path.creatorMaximized = !path.creatorMaximized;
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            int k;

            if (isBezier)
            {
                GUI.color = Color.white;
                EditorGUILayout.BeginHorizontal();
                LTVisualShared.change(ref path.creatorMaximized, EditorGUILayout.Foldout(path.creatorMaximized, "Easy Path Creator", LTEditor.shared.styleAreaFoldout), path, "creator maximized");

                EditorGUILayout.EndHorizontal();

                if (path.creatorMaximized)
                {
                    selectedCreate = (PathCreateType)EditorGUILayout.EnumPopup("Type to create:", selectedCreate);

                    LTVisualShared.change(ref optionsSize, EditorGUILayout.FloatField("Scale:", optionsSize), path, "change scale");
                    switch (selectedCreate)
                    {
                    case PathCreateType.RectangleRounded:
                        optionsBevelSize = EditorGUILayout.Slider("Bevel Size:", optionsBevelSize, 0.0f, 1.399f);
                        break;

                    case PathCreateType.Snake:
                        optionsLength = EditorGUILayout.FloatField("Length:", optionsLength);
                        break;

                    case PathCreateType.Random:
                        optionsLength = EditorGUILayout.FloatField("Length:", optionsLength);
                        EditorGUILayout.LabelField("Min Range:", optionsRangeMin.ToString());
                        EditorGUILayout.LabelField("Max Range:", optionsRangeMax.ToString());
                        EditorGUILayout.MinMaxSlider(ref optionsRangeMin, ref optionsRangeMax, 0.0f, 10.0f);

                        break;

                    case PathCreateType.Circle:
                        optionsSegments = closestSegment(EditorGUILayout.IntSlider("Segments:", optionsSegments, 4, MAX_SPLINES));
                        break;

                    case PathCreateType.Straight:
                        optionsLength    = EditorGUILayout.FloatField("Length:", optionsLength);
                        optionsDirection = EditorGUILayout.Vector3Field("Direction:", optionsDirection);
                        break;

                    default:
                        break;
                    }



                    GUI.color = LTEditor.shared.colorRefresh;
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Create New Path", LTEditor.shared.styleActionButton))
                    {
                        Undo.RecordObject(path, "creating new path");
                        // path.arraySize = count.intValue*4;
                        switch (selectedCreate)
                        {
                        case PathCreateType.RectangleRounded:
                            resetPath();
                            float b = optionsBevelSize;
                            float n = 0.1f;
                            addTo(new Vector3[] {
                                new Vector3(b, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(0f, b, 0f)
                                , new Vector3(0f, b, 0f), new Vector3(0f, b + n, 0f), new Vector3(0f, 3f - b - n, 0f), new Vector3(0f, 3f - b, 0f)
                                , new Vector3(0f, 3f - b, 0f), new Vector3(0f, 3f, 0f), new Vector3(0f, 3f, 0f), new Vector3(b, 3f, 0f)
                                , new Vector3(b, 3f, 0f), new Vector3(3f - b - n, 3f, 0f), new Vector3(b + n, 3f, 0f), new Vector3(3f - b, 3f, 0f)
                                , new Vector3(3f - b, 3f, 0f), new Vector3(3f, 3f, 0f), new Vector3(3f, 3f, 0f), new Vector3(3f, 3f - b, 0f)
                                , new Vector3(3f, 3f - b, 0f), new Vector3(3f, b + n, 0f), new Vector3(3f, b + n, 0f), new Vector3(3f, b, 0f)
                                , new Vector3(3f, b, 0f), new Vector3(3f, 0f, 0f), new Vector3(3f, 0f, 0f), new Vector3(3f - b, 0f, 0f)
                                , new Vector3(3f - b, 0f, 0f), new Vector3(3f - b - n, 0f, 0f), new Vector3(b + n, 0f, 0f), new Vector3(b, 0f, 0f)
                            });
                            break;

                        case PathCreateType.Snake:
                            resetPath();
                            path.path = new Vector3[(int)optionsLength * 4];
                            k         = 0;
                            for (int i = 0; i < path.path.Length; i++)
                            {
                                Vector3 vec3 = pos + new Vector3(k * optionsSize, 0f, k * optionsSize);
                                if (i % 4 == 1)
                                {
                                    vec3.x += 1 * optionsSize;
                                }
                                if (i % 4 == 2)
                                {
                                    vec3.x += -1 * optionsSize;
                                }
                                path.path[i] = vec3;
                                if (i % 2 == 0)
                                {
                                    k++;
                                }
                            }
                            break;

                        case PathCreateType.Random:
                            resetPath();
                            path.path = new Vector3[(int)optionsLength * 4];
                            k         = 0;
                            float rand = 0f;
                            for (int i = 0; i < path.path.Length; i++)
                            {
                                Vector3 vec3 = pos + new Vector3(k * optionsSize, 0f, 0f);

                                if (i % 4 == 1)
                                {
                                    vec3.z += rand * optionsSize;
                                }
                                rand = Random.Range(optionsRangeMin, optionsRangeMax) * optionsSize;
                                if (i % 4 == 2)
                                {
                                    vec3.z += -rand * optionsSize;
                                }
                                path.path[i] = vec3;
                                if (i % 2 == 0)
                                {
                                    k++;
                                }
                            }
                            break;

                        case PathCreateType.Circle:
                            resetPath();
                            //count.intValue = optionsSegments;
                            Vector3[] v = generateCircularQuadraticBezierSegments(optionsSize, optionsSegments);
                            //Debug.Log("v:"+v);
                            addTo(v);
                            break;

                        case PathCreateType.Straight:
                            resetPath();
                            path.path = new Vector3[(int)optionsLength * 4];
                            k         = 0;
                            for (int i = 0; i < path.path.Length; i++)
                            {
                                path.path[i] = pos + k * optionsDirection * optionsSize;
                                if (i % 2 == 0)
                                {
                                    k++;
                                }
                            }
                            break;

                        default:
                            Debug.LogError("Unrecognized Option");
                            break;
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }         // end if creatorMaximized
            }             // end if isBezier

            EditorGUILayout.BeginHorizontal();
            GUI.color = LTEditor.shared.colorRefresh;
            LTVisualShared.change(ref path.nodesMaximized, EditorGUILayout.Foldout(path.nodesMaximized, "Nodes (" + path.count + ")", LTEditor.shared.styleAreaFoldout), path, "nodes maximized");
            //if(GUILayout.Button("Nodes", LTEditor.shared.styleGroupButton))
            //	path.nodesMaximized = !path.nodesMaximized;

            if (path.nodesMaximized)
            {
                if (isBezier)
                {
                    bool refresh = GUILayout.Button("Refresh", GUILayout.Width(65), GUILayout.Height(22));
                    if (refresh)
                    {
                        Undo.RecordObject(path, "path refreshed");
                        Vector3[] from = path.vec3;
                        path.path = new Vector3[from.Length];
                        for (int i = 0; i < from.Length; i++)
                        {
                            path.path[i] = from[i] - pos;
                        }
                        resetPath();
                    }
                }

                GUI.color = LTEditor.shared.colorDestruct;
                bool deleted = GUILayout.Button("Delete All", GUILayout.Width(80), GUILayout.Height(22));
                if (deleted)
                {
                    Undo.RecordObject(path, "deleting all");
                    resetPath();
                }
            }
            EditorGUILayout.EndHorizontal();

            GUI.color = Color.white;
            if (path.nodesMaximized)
            {
                EditorGUILayout.Space();
                bool needsPathScroll = path.pts.Length > 8;
                if (needsPathScroll)
                {
                    scrollPathsViewPos = EditorGUILayout.BeginScrollView(scrollPathsViewPos, GUILayout.Height(150));
                }

                k = 0;
                int j = 0;
                for (int i = 0; i < path.pts.Length; i++)
                {
                    Transform t = path.pts[i];
                    GUI.color = LTEditor.shared.colorNodes;
                    if (t == null)
                    {
                        //EditorGUILayout.LabelField("Nothing here "+i);
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();

                        string label;
                        bool   isControl = true;
                        if (isBezier)
                        {
                            isControl = i == 0 || i % 4 == 3;
                            if (isControl)
                            {
                                label = "  Node" + (j + 1);
                                j++;
                                k = 0;
                            }
                            else
                            {
                                label = "  - Control" + k;
                                k++;
                            }
                        }
                        else
                        {
                            label = "  Node" + i;
                        }
                        Vector3 position = EditorGUILayout.Vector3Field(label, t.localPosition);

                        if (GUI.changed)
                        {
                            Undo.RecordObject(t, "Transform Change " + t.gameObject.name);
                            t.localPosition = FixIfNaN(position);
                        }
                        if (isControl)
                        {
                            GUI.color = LTEditor.shared.colorAdd;
                            if (GUILayout.Button("+", LTEditor.shared.styleOneCharButton))
                            {
                                //Debug.Log("path.pts:"+path.pts);
                                Undo.RecordObject(path, "adding new node");
                                path.addNodeAfter(i);
                                SceneView.RepaintAll();
                                scrollPathsSetToEnd = 2;
                            }
                            if (i == 0)
                            {
                                GUI.color = Color.white * 0f;
                                GUILayout.Button("X", LTEditor.shared.styleOneCharButton);
                            }


                            GUI.color = LTEditor.shared.colorDestruct;
                            if (i != 0 && GUILayout.Button("X", LTEditor.shared.styleOneCharButton))
                            {
                                Undo.RecordObject(t, "Deleted Node " + t.gameObject.name);
                                path.deleteNode(i);
                                // Debug.Log("after:"+path.count);
                                SceneView.RepaintAll();
                            }
                        }
                        else
                        {
                            GUI.color = Color.white * 0f;
                            GUILayout.Button("X", LTEditor.shared.styleOneCharButton);
                            GUILayout.Button("X", LTEditor.shared.styleOneCharButton);
                        }

                        EditorGUILayout.EndHorizontal();
                    }
                }

                if (needsPathScroll)
                {
                    EditorGUILayout.EndScrollView();
                }

                if (scrollPathsSetToEnd > 0)
                {
                    scrollPathsSetToEnd--;
                    scrollPathsViewPos = new Vector2(0, 10000f);
                }

                GUI.color = LTEditor.shared.colorAdd;
                GUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("+ Node", LTEditor.shared.styleActionButton))
                {
                    Undo.RecordObject(path, "adding new node");
                    path.addNode();
                    SceneView.RepaintAll();
                    scrollPathsSetToEnd = 2;
                }
                GUILayout.EndHorizontal();
            }

            GUI.color = Color.white;


            path.importMaximized = EditorGUILayout.Foldout(path.importMaximized, "Import/Export", LTEditor.shared.styleAreaFoldout);
            if (path.importMaximized)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Width(160));
                EditorGUILayout.LabelField("Code Type", GUILayout.Width(80));
                generateCode = EditorGUILayout.Popup(generateCode, new string[] { "C#", "Unityscript" }, GUILayout.Width(80));
                EditorGUILayout.EndHorizontal();

                if (generateCode != generateCodeLast)
                {
                    string codeFormat = generateCode == 0 ? "new Vector3[]{ new Vector3(0f,0f,0f), ... }" : "[ Vector3(0.0,0.0,0.0), ... ]";
                    importArrValue   = "Paste in format: " + codeFormat;
                    generateCodeLast = generateCode;
                }

                EditorGUILayout.LabelField("Exported:", EditorStyles.boldLabel);
                if (Application.isPlaying == false)
                {
                    string outputStr;

                    if (generateCode == 0)
                    {
                        outputStr = "new Vector3[]{ ";
                        for (int i = 0; i < path.pts.Length; i++)
                        {
                            Transform trans = path.pts[i];
                            if (isBezier)
                            {
                                trans = i > 3 && i % 4 == 0 ? path.pts[i - 1] : path.pts[i];
                            }

                            if (trans != null)
                            {
                                outputStr += "new Vector3(" + trans.position.x + "f," + trans.position.y + "f," + trans.position.z + "f)";
                                if (i < path.pts.Length - 1)
                                {
                                    outputStr += ", ";
                                }
                            }
                        }
                        outputStr += " }";
                    }
                    else
                    {
                        outputStr = "[";
                        for (int i = 0; i < path.pts.Length; i++)
                        {
                            Transform trans = path.pts[i];
                            if (isBezier)
                            {
                                trans = i > 3 && i % 4 == 0 ? path.pts[i - 1] : path.pts[i];
                            }
                            if (trans != null)
                            {
                                outputStr += "Vector3(" + trans.position.x + "," + trans.position.y + "," + trans.position.z + ")";
                                if (i < path.pts.Length - 1)
                                {
                                    outputStr += ", ";
                                }
                            }
                        }
                        outputStr += "]";
                    }

                    scrollCodeViewPos = EditorGUILayout.BeginScrollView(scrollCodeViewPos, GUILayout.Height((int)Mathf.Min(70f, path.pts.Length * 7f)));

                    EditorGUILayout.TextArea(outputStr, LTEditor.shared.styleCodeTextArea);

                    EditorGUILayout.EndScrollView();
                }
                else
                {
                    EditorGUILayout.LabelField("    Not available during runtime");
                }

                EditorGUILayout.LabelField("Import:", EditorStyles.boldLabel);

                importArrValue = EditorGUILayout.TextArea(importArrValue, LTEditor.shared.styleCodeTextArea);

                GUI.color = LTEditor.shared.colorRefresh;
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Import Path", LTEditor.shared.styleActionButton))
                {
                    Undo.RecordObject(path, "imported new path");
                    // Debug.Log("index:"+importArrValue.IndexOf("Paste")+" val:"+importArrValue);
                    if (importArrValue.IndexOf("Paste") < 0)
                    {
                        // Debug.Log("Importing");
                        string subImport = "";
                        int    start     = importArrValue.IndexOf("{");
                        int    end       = importArrValue.IndexOf("}");

                        bool cSharpFormat = start >= 0;
                        if (cSharpFormat)
                        {
                            if (start < 0)
                            {
                                Debug.LogError("No starting bracket'{'");
                            }
                            else if (end < 0)
                            {
                                Debug.LogError("No ending bracket'}'");
                            }
                            else
                            {
                                subImport = importArrValue.Substring(start + 1, end - 1 - start).Trim();
                                // Debug.Log("broken down importedArr:"+subImport);
                            }
                        }
                        else
                        {
                            start = importArrValue.IndexOf("[");
                            end   = importArrValue.IndexOf("]");
                            if (start < 0)
                            {
                                Debug.LogError("No starting bracket'['");
                            }
                            else if (end < 0)
                            {
                                Debug.LogError("No ending bracket']'");
                            }
                            else
                            {
                                subImport = importArrValue.Substring(start + 1, end - 1 - start).Trim();
                                // Debug.Log("broken down importedArr:"+subImport);
                            }
                        }

                        string[] stringArr = subImport.Split(new string[] { "Vector3" }, System.StringSplitOptions.RemoveEmptyEntries);
                        int      len       = cSharpFormat ? (stringArr.Length - 1) : stringArr.Length;
                        // Debug.Log("importing length:"+len);
                        resetPath();
                        path.path = new Vector3[len];
                        k         = 0;
                        for (int i = 0; i < stringArr.Length; i++)
                        {
                            start = stringArr[i].IndexOf("("[0]);
                            end   = stringArr[i].IndexOf(")"[0]);
                            // Debug.Log("i:"+i+" start:"+start+" end:"+end);
                            if (start >= 0 && end > 0)
                            {
                                string vecStr = stringArr[i].Substring(start + 1, end - 1 - start);
                                // Debug.Log("vec:"+vecStr);
                                string[] numArr = vecStr.Split(","[0]);
                                for (int j = 0; j < numArr.Length; j++)
                                {
                                    if (numArr[j].IndexOf("("[0]) >= 0)
                                    {
                                        start     = numArr[j].IndexOf("("[0]);
                                        numArr[j] = numArr[j].Substring(start + 1);
                                    }
                                    else if (numArr[j].IndexOf(")"[0]) >= 0)
                                    {
                                        end       = numArr[j].IndexOf(")"[0]);
                                        numArr[j] = numArr[j].Substring(0, end);
                                    }
                                    if (numArr[j].IndexOf("f"[0]) >= 0)
                                    {
                                        end       = numArr[j].IndexOf("f"[0]);
                                        numArr[j] = numArr[j].Substring(0, end);
                                    }
                                    // Debug.Log("num:"+numArr[j]);
                                }

                                Vector3 vec3 = new Vector3(float.Parse(numArr[0]), float.Parse(numArr[1]), float.Parse(numArr[2]));
                                Debug.Log("importing k:" + k + " vec3:" + vec3);
                                path.path[k] = vec3;

                                k++;
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }
        }