Ejemplo n.º 1
0
        void OnEnable()
        {
            if (!texLoaded)
            {
                tex_orb   = EditorResource.LoadEditorTexture("am_orb");
                texLoaded = true;
            }

            window              = this;
            this.maxSize        = new Vector2(715f, 398f);
            this.minSize        = this.maxSize;
            this.wantsMouseMove = true;
            loadAnimatorData();
            setupFilteredCategories();

            selectedIndex = getCategoryIndexForEase(TimelineWindow.GetEaseTypeNameIndex(key.easeType));

            if (getSelectedEaseName(category, selectedIndex) == "Custom")
            {
                isCustomEase = true;
            }
            if (isCustomEase && key.customEase.Count > 0)
            {
                curve = key.getCustomEaseCurve();
            }
            else
            {
                setEasingCurve();
            }
        }
Ejemplo n.º 2
0
        static void DrawGizmos(Animate aData, GizmoType gizmoType)
        {
            //check if it's the one opened
            if (TimelineWindow.window != null && TimelineWindow.window.aData != null && TimelineWindow.window.aData.IsDataMatch(aData))
            {
                AnimateEditControl eData = TimelineWindow.AnimEdit(aData);

                List <Take> _t = eData.takes;

                if (_t == null || _t.Count == 0)
                {
                    return;
                }
                if (eData.currentTakeInd < 0)
                {
                    eData.currentTakeInd = 0;
                }
                else if (eData.currentTakeInd >= _t.Count)
                {
                    eData.currentTakeInd = _t.Count - 1;
                }

                _t[eData.currentTakeInd].drawGizmos(eData.target, AnimateTimeline.e_gizmoSize, Application.isPlaying);
            }
        }
        public ClipCurveEditor(CurveDataSource dataSource, TimelineWindow parentWindow, TrackAsset hostTrack)
        {
            m_DataSource = dataSource;

            m_CurveEditor = new CurveEditor(new Rect(0, 0, 1000, 100), new CurveWrapper[0], false);

            s_CurveEditorSettings.vTickStyle = new TickStyle
            {
                tickColor = { color = DirectorStyles.Instance.customSkin.colorInlineCurveVerticalLines },
                distLabel = 20,
                stubs     = true
            };

            s_CurveEditorSettings.hTickStyle = new TickStyle
            {
                // hide horizontal lines by giving them a transparent color
                tickColor = { color = new Color(0.0f, 0.0f, 0.0f, 0.0f) },
                distLabel = 0
            };

            m_CurveEditor.settings = s_CurveEditorSettings;

            m_ViewModel = TimelineWindowViewPrefs.GetTrackViewModelData(hostTrack);

            m_ShouldRestoreShownArea = true;
            m_CurveEditor.ignoreScrollWheelUntilClicked = true;
            m_CurveEditor.curvesUpdated = OnCurvesUpdated;

            m_BindingHierarchy = new BindingSelector(parentWindow, m_CurveEditor, m_ViewModel.inlineCurvesState);
        }
        static TimelineWindowUtility()
        {
            var assembly = Assembly.Load("UnityEditor.Timeline");

            TimelineWindow = new TimelineWindow(assembly);
            WindowState    = new WindowState(assembly);
            TreeView       = new TimelineTreeViewGUI(assembly);
        }
Ejemplo n.º 5
0
 public static void setValues(Key _key, Track _track)
 {
     justSet = true;
     key     = _key;
     track   = _track;
     //aData = _aData;
     selectedIndex = TimelineWindow.GetEaseTypeNameIndex(key.easeType);
 }
Ejemplo n.º 6
0
        private void OnClickOpenTimeline()
        {
            Skill_Node              node  = Model as Skill_Node;
            TimelineGroupPath       path  = TimelineSetting.Setting.GetSearchPath <SkillTimelineGraphGroupAsset>();
            SkillTimelineGraphAsset asset = TimelineSetting.Setting.GetAsset <SkillTimelineGraphAsset>(path.searchPath, "timeline_" + node.timeline);

            if (asset != null)
            {
                TimelineWindow.Open(asset);
            }
        }
 public BindingSelector(EditorWindow window, CurveEditor curveEditor)
 {
     this.m_Window      = (window as TimelineWindow);
     this.m_CurveEditor = curveEditor;
     this.m_DopeLines   = new ReorderableList(this.m_StringList, typeof(string), false, false, false, false);
     this.m_DopeLines.drawElementBackgroundCallback = null;
     this.m_DopeLines.showDefaultBackground         = false;
     this.m_DopeLines.set_index(0);
     this.m_DopeLines.headerHeight  = 0f;
     this.m_DopeLines.elementHeight = 20f;
     this.m_DopeLines.set_draggable(false);
 }
Ejemplo n.º 8
0
        public BindingSelector(EditorWindow window, CurveEditor curveEditor)
        {
            m_Window      = window as TimelineWindow;
            m_CurveEditor = curveEditor;

            m_DopeLines = new ReorderableList(m_StringList, typeof(string), false, false, false, false);
            m_DopeLines.drawElementBackgroundCallback = null;
            m_DopeLines.showDefaultBackground         = false;
            m_DopeLines.index         = 0;
            m_DopeLines.headerHeight  = 0;
            m_DopeLines.elementHeight = 20;
            m_DopeLines.draggable     = false;
        }
Ejemplo n.º 9
0
        public ClipCurveEditor(CurveDataSource dataSource, TimelineWindow parentWindow, TrackAsset hostTrack)
        {
            m_DataSource = dataSource;

            m_CurveEditor = new CurveEditor(new Rect(0, 0, 1000, 100), new CurveWrapper[0], false);

            s_CurveEditorSettings.hSlider                   = false;
            s_CurveEditorSettings.vSlider                   = false;
            s_CurveEditorSettings.hRangeLocked              = false;
            s_CurveEditorSettings.vRangeLocked              = false;
            s_CurveEditorSettings.scaleWithWindow           = true;
            s_CurveEditorSettings.hRangeMin                 = 0.0f;
            s_CurveEditorSettings.showAxisLabels            = true;
            s_CurveEditorSettings.allowDeleteLastKeyInCurve = true;
            s_CurveEditorSettings.rectangleToolFlags        = CurveEditorSettings.RectangleToolFlags.NoRectangleTool;

            s_CurveEditorSettings.vTickStyle = new TickStyle
            {
                tickColor = { color = DirectorStyles.Instance.customSkin.colorInlineCurveVerticalLines },
                distLabel = 20,
                stubs     = true
            };

            s_CurveEditorSettings.hTickStyle = new TickStyle
            {
                // hide horizontal lines by giving them a transparent color
                tickColor = { color = new Color(0.0f, 0.0f, 0.0f, 0.0f) },
                distLabel = 0
            };

            m_CurveEditor.settings = s_CurveEditorSettings;

            m_ViewModel = TimelineWindowViewPrefs.GetTrackViewModelData(hostTrack);

            if (isNewSelection)
            {
                m_CurveEditor.shownArea = new Rect(1, 1, 1, 1);
            }
            else
            {
                m_CurveEditor.shownAreaInsideMargins = m_ViewModel.inlineCurvesShownAreaInsideMargins;
            }

            m_CurveEditor.ignoreScrollWheelUntilClicked = true;
            m_CurveEditor.curvesUpdated = OnCurvesUpdated;

            m_BindingHierarchy = new BindingSelector(parentWindow, m_CurveEditor, m_ViewModel.inlineCurvesState);
        }
Ejemplo n.º 10
0
        public MainWindow(GraphicsMode gMode) : base(1600, 900, gMode,
                                                     "Cafe Shader Studio",
                                                     GameWindowFlags.Default,
                                                     DisplayDevice.Default,
                                                     3, 2, GraphicsContextFlags.Default)
        {
            Title += ": OpenGL Version: " + GL.GetString(StringName.Version);

            _config        = Config.Load();
            TimelineWindow = new TimelineWindow();
            Outliner       = new Outliner();
            Pipeline       = new Pipeline();
            PropertyWindow = new PropertyWindow();

            status = $"Loading global shaders...";
        }
Ejemplo n.º 11
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _controller = new ImGuiController(Width, Height);

            //Set the current theme instance
            ColorTheme.UpdateTheme(new DarkTheme());

            //Disable the docking buttons
            ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;

            //Enable docking support
            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            //Enable up/down key navigation
            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard;
            //Only move via the title bar instead of the whole window
            ImGui.GetIO().ConfigWindowsMoveFromTitleBarOnly = true;

            //Init rendering data
            TimelineWindow.OnLoad();
            Pipeline.InitBuffers();

            camera_speed = Pipeline._camera.KeyMoveSpeed;

            InitDock();
            LoadRecentList();

            RenderTools.Init();

            ReloadGlobalShaders();

            var Thread2 = new Thread((ThreadStart)(() =>
            {
                //Init plugins
                Toolbox.Core.FileManager.GetFileFormats();
            }));

            Thread2.Start();

            ForceFocused = true;
        }
Ejemplo n.º 12
0
        public void setEasingCurve()
        {
            string name = getSelectedEaseName(category, selectedIndex);

            if (name == "Custom")
            {
                if (curve.length <= 0)
                {
                    curve = getCurve(Ease.Linear);
                    this.Repaint();
                }
                return;
            }

            Ease ease = (Ease)TimelineWindow.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex));

            curve         = getCurve(ease);
            selectedCurve = getCurve(ease);
            this.Repaint();
        }
Ejemplo n.º 13
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            ITimelineGraphAsset graphAsset = target as ITimelineGraphAsset;

            if (GUILayout.Button("Open", GUILayout.Height(30)))
            {
                TimelineWindow.Open(graphAsset);
            }
        }
Ejemplo n.º 14
0
        public TimelineTreeViewGUI(TimelineWindow sequencerWindow, TimelineAsset timeline, Rect rect)
        {
            this.m_Timeline = timeline;
            this.m_Window   = sequencerWindow;
            TreeViewState treeViewState = new TreeViewState();

            this.m_TreeView = new TreeViewController(sequencerWindow, treeViewState);
            this.m_TreeView.set_horizontalScrollbarStyle(GUIStyle.get_none());
            this.m_TimelineTreeView = new TimelineTreeView(sequencerWindow, this.m_TreeView);
            TimelineDragging timelineDragging = new TimelineDragging(this.m_TreeView, this.m_Window, this.m_Timeline);

            this.m_DataSource = new TimelineDataSource(this, this.m_TreeView, sequencerWindow);
            TimelineDataSource expr_7B = this.m_DataSource;

            expr_7B.onVisibleRowsChanged = (Action)Delegate.Combine(expr_7B.onVisibleRowsChanged, new Action(this.m_TimelineTreeView.CalculateRowRects));
            this.m_TreeView.Init(rect, this.m_DataSource, this.m_TimelineTreeView, timelineDragging);
            TreeViewController expr_C0 = this.m_TreeView;

            expr_C0.set_dragEndedCallback((Action <int[], bool>) Delegate.Combine(expr_C0.get_dragEndedCallback(), new Action <int[], bool>(delegate(int[] ids, bool value)
            {
                SelectionManager.Clear();
            })));
            this.m_DataSource.ExpandItems(this.m_DataSource.get_root());
        }
Ejemplo n.º 15
0
        void Update()
        {
            percent += 0.003f * speedValues[selectedSpeedIndex];
            if (percent > 1f + waitPercent)
            {
                percent = waitPercent * -1f;
            }
            float x_pos_start = 50f;
            float x_pos_end   = position.width - 50f - 80f - 200f;

            if (percent <= 1f)
            {
                if (isCustomEase)
                {
                    x_pos = Utility.EaseCustom(x_pos_start, x_pos_end - x_pos_start, percent < 0f ? 0f : percent, curve);
                }
                else
                {
                    var ease = Utility.GetEasingFunction((Ease)TimelineWindow.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex)));
                    x_pos = x_pos_start + (x_pos_end - x_pos_start) * ease(percent < 0f ? 0f : percent, 1.0f, 0.0f, 0.0f);
                }
            }
            this.Repaint();
        }
Ejemplo n.º 16
0
        // Use this for initialization
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            GUIStyle padding = new GUIStyle();

            padding.padding = new RectOffset(4, 4, 4, 4);
            GUILayout.BeginVertical(padding);
            EditorUtility.ResetDisplayControls();
            GUILayout.BeginHorizontal();
            GUILayout.Label(newReference.Count + " possible duplicate" + (newReference.Count > 1 ? "s" : "") + " found:");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Keep: ");
            if (GUILayout.Button("All", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 0;
                }
            }
            if (GUILayout.Button("New", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 1;
                }
            }
            if (GUILayout.Button("Previous", GUILayout.Width(width_button_action)))
            {
                for (int i = 0; i < actions.Count; i++)
                {
                    actions[i] = 2;
                }
            }
            GUILayout.Space(18f);
            GUILayout.EndHorizontal();
            GUILayout.Space(4f);
            GUIStyle styleScrollView = new GUIStyle(GUI.skin.scrollView);

            styleScrollView.normal.background = GUI.skin.GetStyle("GroupElementBG").onNormal.background;
            styleScrollView.padding           = new RectOffset(0, 0, 4, 4);
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, styleScrollView);

            int maxGameObjects = Mathf.CeilToInt((position.height - 62f) / height_gameobject);

            maxGameObjects = Mathf.Clamp(maxGameObjects, 0, newReference.Count);
            int FirstIndex = Mathf.FloorToInt(scrollPos.y / height_gameobject) - 1;

            FirstIndex = Mathf.Clamp(FirstIndex, 0, newReference.Count);
            int LastIndex = FirstIndex + maxGameObjects;

            LastIndex = Mathf.Clamp(LastIndex, 0, newReference.Count);
            if (LastIndex - FirstIndex < maxGameObjects)
            {
                FirstIndex = Mathf.Clamp(LastIndex - maxGameObjects, 0, newReference.Count);
            }

            for (int i = 0; i < newReference.Count; i++)
            {
                if (newReference.Count > maxGameObjects && (i < FirstIndex || i > LastIndex))
                {
                    GUILayout.Space(height_gameobject);
                    continue;
                }
                GUILayout.BeginHorizontal(GUILayout.Height(height_gameobject));
                GUILayout.Label("New: ", GUILayout.Width(40f));
                GUI.enabled = false;
                EditorGUILayout.ObjectField(newReference[i], typeof(GameObject), true, GUILayout.Width(width_object_field));
                GUI.enabled = true;
                GUILayout.Label("Prev: ", GUILayout.Width(40f));
                // do not allow null values
                GameObject go = (GameObject)EditorGUILayout.ObjectField(oldReference[i], typeof(GameObject), true, GUILayout.Width(width_object_field));
                if (go)
                {
                    oldReference[i] = go;
                }
                GUILayout.FlexibleSpace();
                bool keepBoth = actions[i] == 0;
                keepBoth = GUILayout.Toggle(keepBoth, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("Both", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                bool keepFirst = actions[i] == 1;
                keepFirst = GUILayout.Toggle(keepFirst, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("New", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                bool keepSecond = actions[i] == 2;
                keepSecond = GUILayout.Toggle(keepSecond, "");
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset);
                GUILayout.Label("Prev.", GUILayout.Width(width_toggle_label));
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                // set action
                if (keepBoth && actions[i] != 0)
                {
                    actions[i] = 0;
                }
                else if (keepFirst && actions[i] != 1)
                {
                    actions[i] = 1;
                }
                else if (keepSecond && actions[i] != 2)
                {
                    actions[i] = 2;
                }
            }
            GUILayout.EndScrollView();
            GUILayout.Space(4f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                saveChanges();
            }
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Ejemplo n.º 17
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an Animate component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }

            if (mTrack == null)
            {
                return;
            }

            Renderer render = mTrack.GetTarget(aData.target) as Renderer;

            if (!render)
            {
                TimelineWindow.MessageBox("Assign a Renderer to the track first.", TimelineWindow.MessageBoxType.Warning);
                return;
            }

            //select material
            Material[] mats = render.sharedMaterials;

            string[] matNames = new string[mats.Length];
            int[]    matInds  = new int[mats.Length];
            for (int i = 0; i < mats.Length; i++)
            {
                matNames[i] = mats[i].name;
                matInds[i]  = i;
            }

            //grab track info
            int      matInd         = Mathf.Clamp(mTrack.materialIndex, 0, mats.Length - 1);
            Material matOverride    = mTrack.materialOverride;
            string   shaderProperty = mTrack.property;

            //material select
            matInd = EditorGUILayout.IntPopup("Material", matInd, matNames, matInds);

            //material override select
            matOverride = EditorGUILayout.ObjectField("Material Override", matOverride, typeof(Material), false) as Material;

            Material mat = matOverride ? matOverride : mats[matInd];

            //grab material info
            string[] shaderPropertyNames, shaderPropertyDetails;
            MaterialTrack.ValueType[] shaderPropertyTypes;
            int[] shaderPropertyInds;
            GetPropertyInfos(mat, out shaderPropertyNames, out shaderPropertyDetails, out shaderPropertyTypes, out shaderPropertyInds);

            int shaderPropertyInd = -1;

            MaterialTrack.ValueType shaderPropertyType = mTrack.propertyType;

            for (int i = 0; i < shaderPropertyNames.Length; i++)
            {
                if (shaderProperty == shaderPropertyNames[i])
                {
                    shaderPropertyInd = i;

                    //special case for texture offset and scale
                    if (shaderPropertyTypes[i] == MaterialTrack.ValueType.TexEnv && i + 2 < shaderPropertyNames.Length)
                    {
                        if (shaderPropertyType == shaderPropertyTypes[i + 1])
                        {
                            shaderPropertyInd += 1;
                        }
                        else if (shaderPropertyType == shaderPropertyTypes[i + 2])
                        {
                            shaderPropertyInd += 2;
                        }
                    }
                    break;
                }
            }

            if (shaderPropertyInd == -1)
            {
                shaderPropertyInd = 0;
            }

            EditorUtility.DrawSeparator();

            //shader property select
            shaderPropertyInd = EditorGUILayout.IntPopup("Property", shaderPropertyInd, shaderPropertyDetails, shaderPropertyInds);

            shaderProperty     = shaderPropertyNames[shaderPropertyInd];
            shaderPropertyType = shaderPropertyTypes[shaderPropertyInd];

            //check for change
            if (mTrack.materialIndex != matInd || mTrack.materialOverride != matOverride || mTrack.property != shaderProperty || mTrack.propertyType != shaderPropertyType)
            {
                bool applyChanges = true;
                bool deleteKeys   = false;

                //delete if changing type
                if (mTrack.keys.Count > 0 && !MaterialTrack.IsValueTypeCompatible(mTrack.propertyType, shaderPropertyType))
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("Data Will Be Lost", "You will lose all of the keyframes on track '" + mTrack.name + "' if you continue.", "Continue Anway", "Cancel"))
                    {
                        deleteKeys = true;
                    }
                    else
                    {
                        applyChanges = false;
                    }
                }

                if (applyChanges)
                {
                    aData.RegisterTakesUndo("Material Track Property Change");

                    mTrack.materialIndex    = matInd;
                    mTrack.materialOverride = matOverride;
                    mTrack.property         = shaderProperty;
                    mTrack.propertyType     = shaderPropertyType;

                    if (deleteKeys)
                    {
                        mTrack.keys = new List <Key>();
                    }

                    aData.RecordTakesChanged();
                }
            }
        }
Ejemplo n.º 18
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an Animate component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }
            if (track == null)
            {
                return;
            }
            if (!(track.GetTarget(aData.target) as GameObject))
            {
                TimelineWindow.MessageBox("Assign a GameObject to the track first.", TimelineWindow.MessageBoxType.Warning);
                return;
            }
            GUILayout.Label("Select a property to add to track '" + track.name + "'" /*, styleLabel*/);
            scrollView = GUILayout.BeginScrollView(scrollView);
            if (arrComponents != null && arrComponents.Length > 0)
            {
                for (int i = 0; i < arrComponents.Length; i++)
                {
                    // skip behaviours because they may repeat properties
                    // if script is missing (unlikely but it happens in error) then catch and skip
                    try {
                        if (arrComponents[i].GetType() == typeof(Behaviour))
                        {
                            continue;
                        }
                    }
                    catch {
                        continue;
                    }
                    Component myComponent = _go.GetComponent(arrComponents[i].GetType());
                    if (myComponent == null)
                    {
                        continue;
                    }

                    // component button
                    GUILayout.BeginHorizontal(GUILayout.Width(position.width - 5f));
                    string componentName = myComponent.GetType().Name;
                    if (GUILayout.Button(componentName /*,buttonStyle*/))
                    {
                        if (selectionIndex != i)
                        {
                            selectionIndex = i;
                        }
                        else
                        {
                            selectionIndex = -1;
                        }
                    }
                    string lblToggle;
                    if (selectionIndex != i)
                    {
                        lblToggle = "+";
                    }
                    else
                    {
                        lblToggle = "-";
                    }

                    GUILayout.Label(lblToggle, GUILayout.Width(15f));

                    GUILayout.EndHorizontal();

                    if (selectionIndex == i)
                    {
                        //scrollViewComponent = GUILayout.BeginScrollView(scrollViewComponent);
                        int         numberOfProperties = 0;
                        FieldInfo[] fields             = myComponent.GetType().GetFields();
                        // loop through all fields sfields
                        foreach (FieldInfo fieldInfo in fields)
                        {
                            if (!PropertyTrack.isValidType(fieldInfo.FieldType))
                            {
                                // invalid type
                                continue;
                            }
                            // fields
                            GUILayout.BeginHorizontal();
                            // field button
                            if (GUILayout.Button(fieldInfo.Name, GUILayout.Width(150f)))
                            {
                                // select the field
                                processSelectProperty(myComponent, fieldInfo, null);
                            }
                            object val = fieldInfo.GetValue(myComponent);
                            GUILayout.Label(val != null ? val.ToString() : "");
                            GUILayout.EndHorizontal();
                            numberOfProperties++;
                        }
                        PropertyInfo[] properties = myComponent.GetType().GetProperties();
                        // properties
                        foreach (PropertyInfo propertyInfo in properties)
                        {
                            if (propertyInfo.PropertyType == typeof(HideFlags))
                            {
                                continue;
                            }
                            if (shouldIgnoreProperty(propertyInfo.Name))
                            {
                                continue;
                            }
                            if (propertyInfo.CanWrite && PropertyTrack.isValidType(propertyInfo.PropertyType))
                            {
                                object propertyValue;
                                try {
                                    propertyValue = propertyInfo.GetValue(myComponent, null);
                                }
                                catch {
                                    continue;
                                }
                                GUILayout.BeginHorizontal();
                                if (GUILayout.Button(propertyInfo.Name, GUILayout.Width(150f)))
                                {
                                    // select the property
                                    processSelectProperty(myComponent, null, propertyInfo);
                                }

                                GUILayout.Label(propertyValue != null ? propertyValue.ToString() : "null");
                                GUILayout.EndHorizontal();
                                numberOfProperties++;
                            }
                        }
                        if (numberOfProperties <= 0)
                        {
                            GUILayout.Label("No usable properties found");
                        }
                        //GUILayout.EndScrollView();
                    }
                }
            }
            GUILayout.EndScrollView();
        }
Ejemplo n.º 19
0
        public override void DoGUI()
        {
            fsmEditor.OnGUI();

            /* Debug Repaint events
            if (Event.current.type == EventType.repaint)
            {
                Debug.Log("Repaint");
            }*/

            if (Event.current.type == EventType.ValidateCommand)
            {
                switch (Event.current.commandName)
                {
                    case "UndoRedoPerformed":
                    case "Cut":
                    case "Copy":
                    case "Paste":
                    case "SelectAll":
                        Event.current.Use();
                        break;
                }
            }

            if (Event.current.type == EventType.ExecuteCommand)
            {
                switch (Event.current.commandName)
                {
                    /* replaced with Undo.undoRedoPerformed callback added in Unity 4.3
                    case "UndoRedoPerformed":
                        FsmEditor.UndoRedoPerformed();
                        break;
                    */

                    case "Cut":
                        FsmEditor.Cut();
                        break;

                    case "Copy":
                        FsmEditor.Copy();
                        break;

                    case "Paste":
                        FsmEditor.Paste();
                        break;

                    case "SelectAll":
                        FsmEditor.SelectAll();
                        break;

                    case "OpenWelcomeWindow":
                        GetWindow<PlayMakerWelcomeWindow>();
                        break;

                    case "OpenToolWindow":
                        toolWindow = GetWindow<ContextToolWindow>();
                        break;

                    case "OpenFsmSelectorWindow":
                        fsmSelectorWindow = GetWindow<FsmSelectorWindow>();
                        fsmSelectorWindow.ShowUtility();
                        break;

                    case "OpenFsmTemplateWindow":
                        fsmTemplateWindow = GetWindow<FsmTemplateWindow>();
                        break;

                    case "OpenStateSelectorWindow":
                        stateSelectorWindow = GetWindow<FsmStateWindow>();
                        break;

                    case "OpenActionWindow":
                        actionWindow = GetWindow<FsmActionWindow>();
                        break;

                    case "OpenGlobalEventsWindow":
                        globalEventsWindow = GetWindow<FsmEventsWindow>();
                        break;

                    case "OpenGlobalVariablesWindow":
                        globalVariablesWindow = GetWindow<FsmGlobalsWindow>();
                        break;

                    case "OpenErrorWindow":
                        errorWindow = GetWindow<FsmErrorWindow>();
                        break;

                    case "OpenTimelineWindow":
                        timelineWindow = GetWindow<FsmTimelineWindow>();
                        break;

                    case "OpenFsmLogWindow":
                        logWindow = GetWindow<FsmLogWindow>();
                        break;

                    case "OpenAboutWindow":
                        aboutWindow = GetWindow<AboutWindow>();
                        break;

                    case "OpenReportWindow":
                        reportWindow = GetWindow<ReportWindow>();
                        break;

                    case "AddFsmComponent":
                        PlayMakerMainMenu.AddFsmToSelected();
                        break;

                    case "RepaintAll":
                        RepaintAllWindows();
                        break;

                    case "ChangeLanguage":
                        ResetWindowTitles();
                        break;
                }

                GUIUtility.ExitGUI();
            }
        }
Ejemplo n.º 20
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an Animate component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }

            //AMTake curTake = aData.getCurrentTake();

            GUIStyle styleArea = new GUIStyle(GUI.skin.scrollView);

            styleArea.padding = new RectOffset(4, 4, 4, 4);
            GUILayout.BeginArea(new Rect(0f, 0f, position.width, position.height), styleArea);
            //GUILayout.Label("Take: " + curTake.name + " of "+aData.gameObject.name + " "+curTake.GetHashCode());
            GUILayout.Label("Loop");
            GUILayout.Space(2f);
            GUILayout.BeginHorizontal(GUI.skin.box);
            EditorGUIUtility.labelWidth = 50f; EditorGUIUtility.fieldWidth = 100f;
            loopCount = EditorGUILayout.IntField("Count", loopCount);
            if (loopCount < 0)
            {
                loopCount = -1;
            }
            loopMode = (LoopType)EditorGUILayout.EnumPopup("Mode", loopMode);
            GUILayout.EndHorizontal();

            EditorUtility.ResetDisplayControls();

            GUILayout.Space(2f);
            //pausePreviousTake = EditorGUILayout.Toggle("Pause Prev. Take", pausePreviousTake);

            GUILayout.Space(4f);
            bool loopBackFrameEnabled = loopCount < 0;

            GUI.enabled = loopBackFrameEnabled;
            GUILayout.BeginHorizontal();
            loopBackFrameCheck = EditorGUILayout.Toggle(loopBackFrameCheck, GUILayout.Width(12f));
            GUI.enabled        = loopBackFrameEnabled && loopBackFrameCheck;
            loopBackFrame      = EditorGUILayout.IntSlider("Loop Back To Frame", loopBackFrame, 1, totalFrames);
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(6f);
            GUILayout.Label("End Frame Padding");
            GUILayout.Space(2f);
            GUI.enabled     = !loopBackFrameEnabled || !loopBackFrameCheck || loopBackFrame < 0;
            endFramePadding = EditorGUILayout.IntField(endFramePadding, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
            if (endFramePadding < 0)
            {
                endFramePadding = 0;
            }
            GUI.enabled = true;
            GUILayout.Space(2f);
            GUILayout.Label("Frame Rate (Fps)");
            GUILayout.Space(2f);
            frameRate = EditorGUILayout.IntField(frameRate, GUI.skin.textField, GUILayout.Width(position.width - 10f - 12f));
            if (frameRate <= 0)
            {
                frameRate = 1;
            }
            GUILayout.Space(7f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                saveChanges = true;
                this.Close();
            }
            if (GUILayout.Button("Cancel"))
            {
                saveChanges = false;
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Ejemplo n.º 21
0
 public TimelineDragging(TreeViewController treeView, TimelineWindow window, TimelineAsset data) : base(treeView)
 {
     this.m_Timeline = data;
     this.m_Window   = window;
 }
Ejemplo n.º 22
0
        public override void OnInspectorGUI()
        {
            Animate anim = target as Animate;

            GUILayout.BeginVertical();

            //meta
            AnimateMeta curMeta = aData.meta;
            AnimateMeta newMeta = EditorGUILayout.ObjectField(new GUIContent("Meta", "Use data from the reference AnimateMeta. Note: All modifications to the animation will be saved to the Meta."), curMeta, typeof(AnimateMeta), false) as AnimateMeta;

            if (curMeta != newMeta)
            {
                bool doIt = true;
                if (curMeta == null)
                {
                    doIt = UnityEditor.EditorUtility.DisplayDialog("Set Meta", "Setting the Meta will replace the current animation data, proceed?", "Yes", "No");
                }

                if (doIt)
                {
                    aData.MetaSet(newMeta, false);

                    curMeta = aData.meta;
                }
            }

            MetaCommand metaComm = MetaCommand.None;

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            //Save As
            GUI.backgroundColor = Color.green;

            if (GUILayout.Button("Save As...", GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.SaveAs;
            }
            //

            //Break
            GUI.enabled = curMeta != null;

            GUI.backgroundColor = Color.white;

            if (GUILayout.Button(new GUIContent("Break", "This will copy all data from AnimateMeta to this Animate, and then removes the reference to AnimateMeta."), GUILayout.Width(100f)))
            {
                metaComm = MetaCommand.Instantiate;
            }

            GUI.enabled = true;
            //

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorUtility.DrawSeparator();
            //

            List <Take> takes        = aData.takes;
            string      playTakeName = aData.defaultTakeName;
            int         playTakeInd  = 0;

            if (!string.IsNullOrEmpty(playTakeName))
            {
                for (int i = 0; i < takes.Count; i++)
                {
                    if (takes[i].name == aData.defaultTakeName)
                    {
                        playTakeInd = i + 1;
                        break;
                    }
                }
            }

            GenerateTakeLabels();
            int newPlayTakeInd = EditorGUILayout.IntPopup("Play On Start", playTakeInd, mTakeLabels, null);

            if (newPlayTakeInd != playTakeInd)
            {
                aData.RegisterUndo("Set Play On Start", false);
                aData.defaultTakeName = newPlayTakeInd <= 0 ? "" : takes[newPlayTakeInd - 1].name;
            }

            bool isglobal = GUILayout.Toggle(aData.isGlobal, "Global");

            if (aData.isGlobal != isglobal)
            {
                aData.RegisterUndo("Set Global", false);
                aData.isGlobal = isglobal;
                if (isglobal)
                {
                    //uncheck isGlobal to any other animator data on scene
                    Animate[] anims = FindObjectsOfType <Animate>();
                    for (int i = 0; i < anims.Length; i++)
                    {
                        if (!aData.IsDataMatch(anims[i]) && anims[i].isGlobal)
                        {
                            anims[i].isGlobal = false;
                        }
                    }
                }
            }

            var sequenceLoadAll = GUILayout.Toggle(anim.sequenceLoadAll, "Build All Sequence On Start");

            if (anim.sequenceLoadAll != sequenceLoadAll)
            {
                aData.RegisterUndo("Set Sequence Load All", false);
                anim.sequenceLoadAll = sequenceLoadAll;
            }

            var sequenceKillWhenDone = GUILayout.Toggle(anim.sequenceKillWhenDone, "Kill Sequence When Done");

            if (anim.sequenceKillWhenDone != sequenceKillWhenDone)
            {
                aData.RegisterUndo("Set Sequence Kill All When Done", false);
                anim.sequenceKillWhenDone = sequenceKillWhenDone;
            }

            var playOnEnable = GUILayout.Toggle(anim.playOnEnable, "Play On Enable");

            if (anim.playOnEnable != playOnEnable)
            {
                aData.RegisterUndo("Set Play On Enable", false);
                anim.playOnEnable = playOnEnable;
            }

            var onDisableAction = (Animate.DisableAction)EditorGUILayout.EnumPopup("On Disable", anim.onDisableAction);

            if (anim.onDisableAction != onDisableAction)
            {
                aData.RegisterUndo("Set On Disable Action", false);
                anim.onDisableAction = onDisableAction;
            }

            var updateType = (DG.Tweening.UpdateType)EditorGUILayout.EnumPopup("Update", anim.updateType);

            if (anim.updateType != updateType)
            {
                aData.RegisterUndo("Set Update Type", false);
                anim.updateType = updateType;
            }

            var updateTimeIndependent = EditorGUILayout.Toggle("Time Independent", anim.updateTimeIndependent);

            if (anim.updateTimeIndependent != updateTimeIndependent)
            {
                aData.RegisterUndo("Set Time Independent", false);
                anim.updateTimeIndependent = updateTimeIndependent;
            }

            if (!Application.isPlaying && aData.gameObject.scene.IsValid())
            {
                TimelineWindow timeline = TimelineWindow.window;

                if (timeline != null && timeline.aData != null && aData.target == timeline.aData.target)
                {
                    if (GUILayout.Button("Deselect"))
                    {
                        timeline.aData = null;
                        timeline.Repaint();

                        if (Selection.activeGameObject == aData.gameObject)
                        {
                            Selection.activeGameObject = null;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("Edit Timeline"))
                    {
                        if (timeline != null)
                        {
                            timeline.aData = aData;
                            timeline.Repaint();
                        }
                        else
                        {
                            EditorWindow.GetWindow(typeof(TimelineWindow));
                        }
                    }
                }
            }

            //display missings
            string[] missings = aData.target.GetMissingTargets();
            if (missings != null && missings.Length > 0)
            {
                EditorUtility.DrawSeparator();
                mMissingsFoldout = EditorGUILayout.Foldout(mMissingsFoldout, string.Format("Missing Targets [{0}]", missings.Length));
                if (mMissingsFoldout)
                {
                    for (int i = 0; i < missings.Length; i++)
                    {
                        GUILayout.Label(missings[i]);
                    }
                }

                //fix missing targets
                if (GUILayout.Button("Generate Missing Targets"))
                {
                    aData.target.GenerateMissingTargets(missings);
                }
            }

            GUILayout.EndVertical();

            switch (metaComm)
            {
            case MetaCommand.SaveAs:
                string path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save AnimateMeta", aData.name, "asset", "Please enter a file name to save the animator data to");
                if (!string.IsNullOrEmpty(path))
                {
                    bool canCreate = true;

                    //check if path is the same as current
                    if (aData.meta)
                    {
                        string curPath = AssetDatabase.GetAssetPath(aData.meta);
                        if (path == curPath)
                        {
                            canCreate = false;     //don't need to save this since it's already being used.
                        }
                    }

                    if (canCreate)
                    {
                        //check if it already exists
                        if (!string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(path)))
                        {
                            //load the meta and overwrite its data
                            var loadedMeta = AssetDatabase.LoadAssetAtPath <AnimateMeta>(path);
                            aData.MetaSet(loadedMeta, true);
                        }
                        else
                        {
                            //create new meta
                            var createdMeta = ScriptableObject.CreateInstance <AnimateMeta>();
                            AssetDatabase.CreateAsset(createdMeta, path);
                            AssetDatabase.SaveAssets();

                            aData.MetaSet(createdMeta, true);
                        }
                    }
                }
                break;

            case MetaCommand.Instantiate:
                //warning if there are missing targets
                bool doIt = true;
                if (missings != null && missings.Length > 0)
                {
                    doIt = UnityEditor.EditorUtility.DisplayDialog("Break Animator Meta", "There are missing targets, some keys will be removed. Do you want to proceed?", "Yes", "No");
                }
                if (doIt)
                {
                    aData.MetaSet(null, true);
                    aData.currentTakeInd = 0;
                    GUI.changed          = true;
                }
                break;
            }

            if (GUI.changed)
            {
                if (TimelineWindow.window)
                {
                    if (metaComm != MetaCommand.None)
                    {
                        TimelineWindow.window.Reload();
                    }
                    else
                    {
                        TimelineWindow.window.Repaint();
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public override void Update(Vector2 OFFSET)
        {
            //access to TimelineWindow
            if (timelineWindow == null)
            {
                timelineWindow = (TimelineWindow)ObjManager.Windows.Find(x => x.GetType().Name == "TimelineWindow");
                if (timelineWindow != null && timelineWindow.delete)
                {
                    timelineWindow = null;                                                  //prevent reasignment before old window could be deleted
                }
            }

            if (Globals.mouse.LeftClickHold() && Globals.interactWindow == null)
            {
                //access to ColorPickerWindow
                if (cp == null)
                {
                    cp = (ColorPickerWindow)ObjManager.Windows.Find(x => x.GetType().Name == "ColorPickerWindow");
                    if (cp != null && cp.delete)
                    {
                        cp = null;                          //prevent reasignment before old window could be deleted
                    }
                }
                else
                {
                    Vector2 newDrawPos = new Vector2((float)Math.Ceiling((Globals.mouse.newMousePos.X - offset.X - pos.X) / zoom), (float)Math.Ceiling((Globals.mouse.newMousePos.Y - offset.Y - pos.Y) / zoom));
                    Vector2 oldDrawPos = new Vector2((float)Math.Ceiling((Globals.mouse.oldMousePos.X - offset.X - pos.X) / zoom), (float)Math.Ceiling((Globals.mouse.oldMousePos.Y - offset.Y - pos.Y) / zoom));

                    switch (Globals.activeTool)
                    {
                    case ("Brush"):
                        drawLine(oldDrawPos, newDrawPos, cp.currentColor);      //draw a line since the mouse "teleports" across the screen
                        break;

                    case ("Eraser"):
                        drawLine(oldDrawPos, newDrawPos, Color.Transparent);
                        break;

                    case ("BucketFill"):
                        FloodFill(newDrawPos, cp.currentColor);
                        break;

                    case ("EyeDropper"):
                        if (window.MouseInWindow())
                        {
                            cp.setColor(getPixel(newDrawPos));
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            for (int i = 0; i < textures.Count; i++)    //turn pixels (from the frames) into textures
            {
                textures[i].SetData <UInt32>(pixelsList[i], 0, (int)dim.X * (int)dim.Y);
            }
            if (timelineWindow != null && timelineWindow.osActive)  //get onion skin textures
            {
                predFrames = Enumerable.Repeat <Texture2D>(new Texture2D(Globals.graphicsDevice, (int)Globals.canvas.dim.X, (int)Globals.canvas.dim.Y, false, SurfaceFormat.Color), textures.Count).ToList();
                succFrames = Enumerable.Repeat <Texture2D>(new Texture2D(Globals.graphicsDevice, (int)Globals.canvas.dim.X, (int)Globals.canvas.dim.Y, false, SurfaceFormat.Color), textures.Count).ToList();

                if (timelineWindow.timeline.currentFrame > 0)
                {
                    for (int i = 0; i < predFrames.Count; i++)
                    {
                        predFrames[i].SetData <UInt32>(timelineWindow.timeline.Layers[i].Frames[timelineWindow.timeline.currentFrame - 1].pixels);
                    }
                }
                try
                {
                    if (timelineWindow.timeline.currentFrame < timelineWindow.timeline.Layers[0].Frames.Count - 1)
                    {
                        for (int i = 0; i < succFrames.Count; i++)
                        {
                            succFrames[i].SetData <UInt32>(timelineWindow.timeline.Layers[i].Frames[timelineWindow.timeline.currentFrame + 1].pixels);
                        }
                    }
                }
                catch { }
            }
            else
            {
                predFrames = new List <Texture2D>();
                succFrames = new List <Texture2D>();
            }
            base.Update(OFFSET + offset);
        }
Ejemplo n.º 24
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an AnimatorData component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }
            if (!oData)
            {
                oData = OptionsFile.loadFile();
            }
            GUILayout.BeginHorizontal();
            #region tab selection
            //GUI.DrawTexture(new Rect(0f,0f,120f,position.height),GUI.skin.GetStyle("GroupElementBG")/*GUI.skin.GetStyle("GroupElementBG").onNormal.background*/);
            GUIStyle styleTabSelectionBG = new GUIStyle(GUI.skin.GetStyle("GroupElementBG"));
            styleTabSelectionBG.normal.background = EditorStyles.toolbar.normal.background;
            GUILayout.BeginVertical(/*GUI.skin.GetStyle("GroupElementBG")*/ styleTabSelectionBG, GUILayout.Width(121f));
            EditorUtility.ResetDisplayControls();
            GUIStyle styleTabButton = new GUIStyle(EditorStyles.toolbarButton);
            styleTabButton.fontSize             = 12;
            styleTabButton.fixedHeight          = 30;
            styleTabButton.onNormal.background  = styleTabButton.onActive.background;
            styleTabButton.onFocused.background = null;
            styleTabButton.onHover.background   = null;
            tabIndex = GUILayout.SelectionGrid(tabIndex, tabNames, 1, styleTabButton);
            GUILayout.EndVertical();
            #endregion
            #region options
            GUILayout.BeginVertical();
            EditorUtility.ResetDisplayControls();

            GUIStyle styleArea = new GUIStyle(GUI.skin.textArea);
            scrollView = GUILayout.BeginScrollView(scrollView, styleArea);
            List <string> takeNames = getTakeNames();

            GUIStyle styleTitle = new GUIStyle(GUI.skin.label);
            styleTitle.fontSize  = 20;
            styleTitle.fontStyle = FontStyle.Bold;

            // tab title
            GUILayout.BeginHorizontal();
            GUILayout.Space(width_indent);
            GUILayout.Label(tabNames[tabIndex], styleTitle);
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);

            #region general
            if (tabIndex == (int)tabType.General)
            {
                List <string> takeNamesWithNone = new List <string>(takeNames);
                takeNamesWithNone.Insert(0, "None");

                // gizmo size
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(80f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Gizmo size", GUILayout.Width(80f));
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();

                float newGizmoSize = GUILayout.HorizontalSlider(oData.gizmo_size, 0f, 0.1f, GUILayout.ExpandWidth(true));
                if (oData.gizmo_size != newGizmoSize)
                {
                    oData.gizmo_size            = newGizmoSize;
                    AnimateTimeline.e_gizmoSize = newGizmoSize;
                    GUIUtility.keyboardControl  = 0;
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                GUILayout.BeginVertical(GUILayout.Height(26f), GUILayout.Width(75f));
                GUILayout.FlexibleSpace();
                newGizmoSize = EditorGUILayout.FloatField(oData.gizmo_size, GUI.skin.textField, GUILayout.Width(75f));
                if (oData.gizmo_size != newGizmoSize)
                {
                    oData.gizmo_size            = newGizmoSize;
                    AnimateTimeline.e_gizmoSize = newGizmoSize;
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                // pixel/unit default
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 250.0f;
                float ppu = EditorGUILayout.FloatField("Pixel/Unit Default", oData.pixelPerUnitDefault);
                if (ppu <= 0.001f)
                {
                    ppu = 0.001f;
                }
                if (oData.pixelPerUnitDefault != ppu)
                {
                    oData.pixelPerUnitDefault = ppu;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(4.0f);
                // dynamic max frames
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 100.0f;
                var lastFieldWidth = EditorGUIUtility.fieldWidth;
                EditorGUIUtility.fieldWidth = 50.0f;
                int fpp = EditorGUILayout.IntField("Frames/Page", oData.framesPerPage);
                if (fpp < 15)
                {
                    fpp = 15;
                }
                if (oData.framesPerPage != fpp)
                {
                    oData.framesPerPage = fpp;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }

                int mp = EditorGUILayout.IntField("Max Page", oData.maxPage);
                if (mp < 1)
                {
                    mp = 1;
                }
                if (oData.maxPage != mp)
                {
                    oData.maxPage = mp;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(4.0f);
                EditorGUIUtility.fieldWidth = lastFieldWidth;
                // sprite drag/drop fps
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                EditorGUIUtility.labelWidth = 250.0f;
                int nfps = EditorGUILayout.IntField("Sprite Insert Frame/Second", oData.spriteInsertFramePerSecond);
                if (nfps <= 0)
                {
                    nfps = 1;
                }
                if (oData.spriteInsertFramePerSecond != nfps)
                {
                    oData.spriteInsertFramePerSecond = nfps;
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // time instead of frame numbers
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Show time instead of frame numbers");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setTimeNumbering(GUILayout.Toggle(oData.time_numbering, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // scrubby zoom cursor
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Scrubby zoom cursor");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setScrubbyZoomCursor(GUILayout.Toggle(oData.scrubby_zoom_cursor, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // scrubby zoom slider
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Scrubby zoom slider");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setScrubbyZoomSlider(GUILayout.Toggle(oData.scrubby_zoom_slider, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // show warning for lost references

                /*GUILayout.BeginHorizontal();
                 *      GUILayout.Space(width_indent);
                 *      GUILayout.BeginVertical(GUILayout.Height(26f));
                 *          GUILayout.FlexibleSpace();
                 *          GUILayout.Label ("Show warning for lost references");
                 *          GUILayout.FlexibleSpace();
                 *      GUILayout.EndVertical();
                 *      if(oData.setShowWarningForLostReferences(GUILayout.Toggle(oData.showWarningForLostReferences,""))) {
                 *          // save
                 *          EditorUtility.SetDirty(oData);
                 *      }
                 *  GUILayout.EndHorizontal();*/
                // ignore minimum window size warning
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Ignore minimum window size warning");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setIgnoreMinimumSizeWarning(GUILayout.Toggle(oData.ignoreMinSize, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // show frames for collapsed tracks
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Show frames for collapsed tracks");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setShowFramesForCollapsedTracks(GUILayout.Toggle(oData.showFramesForCollapsedTracks, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
                // disable timeline actions
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Hide Timeline Actions (May increase editor performance)");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setDisableTimelineActions(GUILayout.Toggle(oData.disableTimelineActions, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                    TimelineWindow.recalculateNumFramesToRender();
                }
                GUILayout.EndHorizontal();
                // disable timeline actions tooltip
                if (oData.disableTimelineActions)
                {
                    GUI.enabled = false;
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Enable Timeline Actions tooltip");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.disableTimelineActions)
                {
                    GUILayout.Toggle(false, "");
                }
                else
                {
                    if (oData.setDisableTimelineActionsTooltip(!GUILayout.Toggle(!oData.disableTimelineActionsTooltip, "")))
                    {
                        // save
                        UnityEditor.EditorUtility.SetDirty(oData);
                    }
                }
                GUILayout.EndHorizontal();
                // reset takes on close
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical(GUILayout.Height(26f));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Reset Take On Close");
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (oData.setResetTakeOnClose(GUILayout.Toggle(oData.resetTakeOnClose, "")))
                {
                    // save
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region quick add
            else if (tabIndex == (int)tabType.QuickAdd)
            {
                EditorUtility.ResetDisplayControls();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.Label("Combinations");
                GUILayout.EndHorizontal();
                if (oData.quickAdd_Combos == null)
                {
                    oData.quickAdd_Combos = new List <List <int> >();
                }
                for (int j = 0; j < oData.quickAdd_Combos.Count; j++)
                {
                    GUILayout.Space(3f);
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(width_indent);
                    for (int i = 0; i < oData.quickAdd_Combos[j].Count; i++)
                    {
                        if (oData.setQuickAddCombo(j, i, EditorGUILayout.Popup(oData.quickAdd_Combos[j][i], SerializeTypeEditor.TrackNames, GUILayout.Width(80f))))
                        {
                            oData.flatten_quickAdd_Combos();
                            UnityEditor.EditorUtility.SetDirty(oData);
                        }
                        if (i < oData.quickAdd_Combos[j].Count - 1)
                        {
                            GUILayout.Label("+");
                        }
                    }
                    GUILayout.FlexibleSpace();
                    if (oData.quickAdd_Combos[j].Count > 0)
                    {
                        if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(20f)))
                        {
                            oData.quickAdd_Combos[j].RemoveAt(oData.quickAdd_Combos[j].Count - 1);
                            if (oData.quickAdd_Combos[j].Count == 0)
                            {
                                oData.quickAdd_Combos.RemoveAt(j);
                                j--;
                            }
                            oData.flatten_quickAdd_Combos();
                            UnityEditor.EditorUtility.SetDirty(oData);
                        }
                    }
                    if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
                    {
                        oData.quickAdd_Combos[j].Add((int)SerializeType.Translation);
                        oData.flatten_quickAdd_Combos();
                        UnityEditor.EditorUtility.SetDirty(oData);
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                if (oData.quickAdd_Combos.Count <= 0)
                {
                    GUILayout.Space(width_indent);
                    GUILayout.Label("Click '+' to add a new combination");
                }
                GUILayout.FlexibleSpace();
                // new combo
                if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(20f)))
                {
                    oData.quickAdd_Combos.Add(new List <int> {
                        (int)SerializeType.Translation
                    });
                    oData.flatten_quickAdd_Combos();
                    UnityEditor.EditorUtility.SetDirty(oData);
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region import / export
            else if (tabIndex == (int)tabType.ImportExport)
            {
                GUIStyle labelRight = new GUIStyle(GUI.skin.label);
                labelRight.alignment = TextAnchor.MiddleRight;
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal(GUILayout.Width(300f));
                GUILayout.Space(width_indent);
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                GUILayout.Label("Take(s):", labelRight, GUILayout.Width(55f));
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                if (GUILayout.Button("Import", GUILayout.Width(60f)))
                {
                    //TODO: undo "Import Take(s)"
                    string importTakesPath = UnityEditor.EditorUtility.OpenFilePanel("Import Take(s)", "Assets/", "unity");
                    if (importTakesPath != "")
                    {
                        TakeImport.openAdditiveAndDeDupe(importTakesPath);
                    }
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(1f);
                if (GUILayout.Button("Export:", GUILayout.Width(60f)))
                {
                    if (!exportAllTakes)
                    {
                        TakeExport.take = aData.GetTake(takeNames[exportTakeIndex]);
                    }
                    else
                    {
                        TakeExport.take = null;
                    }
                    //TakeExport.aData = aData;
                    //EditorWindow.GetWindow (typeof (TakeExport)).ShowUtility();
                    EditorWindow windowExport = ScriptableObject.CreateInstance <TakeExport>();
                    windowExport.ShowUtility();
                }
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                exportAllTakes = (GUILayout.Toggle(!exportAllTakes, "") ? false : exportAllTakes);
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(4f);
                setExportTakeIndex(EditorGUILayout.Popup(exportTakeIndex, takeNames.ToArray(), GUILayout.Width(100f)));
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                exportAllTakes = (GUILayout.Toggle(exportAllTakes, "") ? true : exportAllTakes);
                GUILayout.EndVertical();
                GUILayout.BeginVertical();
                GUILayout.Space(2f);
                GUILayout.Label("All Takes");
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal();
                GUILayout.Space(width_indent);
                GUILayout.Label("Options:", labelRight, GUILayout.Width(55f));
                if (GUILayout.Button("Import", GUILayout.Width(60f)))
                {
                    //TODO: undo for "Import Options"
                    string importOptionsPath = UnityEditor.EditorUtility.OpenFilePanel("Import Options", "Assets/Animator", "unitypackage");
                    if (importOptionsPath != "")
                    {
                        AssetDatabase.ImportPackage(importOptionsPath, true);
                        this.Close();
                    }
                }
                if (GUILayout.Button("Export", GUILayout.Width(60f)))
                {
                    OptionsFile.export();
                }
                GUILayout.EndHorizontal();
            }
            #endregion
            #region about
            else if (tabIndex == (int)tabType.About)
            {
                GUILayout.Space(3f);

                string message = "Animator v" + version + ", Originally by Abdulla Ameen (c) 2012.  Modified by David Dionisio under the Creative Commons Attribution-NonCommercial 3.0 Unported License.\n\nPlease have a look at the documentation if you need help, or e-mail [email protected] for further assistance.";
                message += "\n\nHOTween by Daniele Giardini\n\nAdditional code contributions by:\nQuick Fingers, Eric Haines";
                GUIStyle styleInfo = new GUIStyle(GUI.skin.label);
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                styleInfo.wordWrap = true;
                GUILayout.Label(message, styleInfo);
                GUILayout.EndHorizontal();
            }
            #endregion
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            #endregion
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 25
0
        private void DrawViewportMenu()
        {
            if (ImGui.BeginMenu("View Setting"))
            {
                if (ImGui.BeginMenu("Background"))
                {
                    ImGui.Checkbox("Display", ref DrawableBackground.Display);
                    ImGui.ColorEdit3("Color Top", ref DrawableBackground.BackgroundTop);
                    ImGui.ColorEdit3("Color Bottom", ref DrawableBackground.BackgroundBottom);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Grid"))
                {
                    ImGui.Checkbox("Display", ref DrawableFloor.Display);
                    ImGui.ColorEdit4("Grid Color", ref DrawableFloor.GridColor);
                    ImGui.InputInt("Grid Cell Count", ref Toolbox.Core.Runtime.GridSettings.CellAmount);
                    ImGui.InputFloat("Grid Cell Size", ref Toolbox.Core.Runtime.GridSettings.CellSize);
                    ImGui.EndMenu();
                }
                if (ImGui.BeginMenu("Bones"))
                {
                    ImGui.Checkbox("Display", ref Runtime.DisplayBones);
                    ImGui.InputFloat("Point Size", ref Runtime.BonePointSize);
                    ImGui.EndMenu();
                }

                if (ImGui.Checkbox("Mesh Picking", ref Pipeline._context.ColorPicker.EnablePicking))
                {
                    if (!Pipeline._context.ColorPicker.EnablePicking)
                    {
                        Pipeline._context.Scene.ResetSelected();
                    }
                }
                ImGui.Checkbox("Wireframe", ref Toolbox.Core.Runtime.RenderSettings.Wireframe);
                ImGui.Checkbox("WireframeOverlay", ref Toolbox.Core.Runtime.RenderSettings.WireframeOverlay);
                ImGui.Checkbox("Bounding Boxes", ref Toolbox.Core.Runtime.RenderBoundingBoxes);
                ImGui.Checkbox("Enable Bloom", ref Pipeline._context.EnableBloom);


                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu($"Shading: [{Runtime.DebugRendering}]"))
            {
                foreach (var mode in Enum.GetValues(typeof(Runtime.DebugRender)))
                {
                    bool isSelected = (Runtime.DebugRender)mode == Runtime.DebugRendering;
                    if (ImGui.Selectable(mode.ToString(), isSelected))
                    {
                        Runtime.DebugRendering = (Runtime.DebugRender)mode;
                    }
                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }
                ImGui.EndMenu();
            }

            if (ImGui.BeginMenu("Camera"))
            {
                if (ImGui.Button("Reset Transform"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.ComboFromEnum <Camera.FaceDirection>("Direction", Pipeline._context.Camera, "Direction");
                if (ImGuiHelper.ComboFromEnum <Camera.CameraMode>("Mode", Pipeline._context.Camera, "Mode"))
                {
                    Pipeline._context.Camera.ResetViewportTransform();
                }

                ImGuiHelper.InputFromBoolean("Orthographic", Pipeline._context.Camera, "IsOrthographic");
                ImGuiHelper.InputFromBoolean("Lock Rotation", Pipeline._context.Camera, "LockRotation");

                ImGuiHelper.InputFromFloat("Fov (Degrees)", Pipeline._context.Camera, "FovDegrees", true, 1f);
                if (Pipeline._context.Camera.FovDegrees != 45)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.FovDegrees = 45;
                    }
                }

                ImGuiHelper.InputFromFloat("ZFar", Pipeline._context.Camera, "ZFar", true, 1f);
                if (Pipeline._context.Camera.ZFar != 100000.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZFar = 100000.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("ZNear", Pipeline._context.Camera, "ZNear", true, 0.1f);
                if (Pipeline._context.Camera.ZNear != 0.1f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZNear = 0.1f;
                    }
                }

                ImGuiHelper.InputFromFloat("Zoom Speed", Pipeline._context.Camera, "ZoomSpeed", true, 0.1f);
                if (Pipeline._context.Camera.ZoomSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.ZoomSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Pan Speed", Pipeline._context.Camera, "PanSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("Reset"))
                    {
                        Pipeline._context.Camera.PanSpeed = 1.0f;
                    }
                }

                ImGuiHelper.InputFromFloat("Key Move Speed", Pipeline._context.Camera, "KeyMoveSpeed", true, 0.1f);
                if (Pipeline._context.Camera.PanSpeed != 1.0f)
                {
                    ImGui.SameLine(); if (ImGui.Button("KeyMoveSpeed"))
                    {
                        Pipeline._context.Camera.KeyMoveSpeed = 1.0f;
                    }
                }

                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Reset Animations"))
            {
                TimelineWindow.Reset();
                ImGui.EndMenu();
            }

            ImGui.AlignTextToFramePadding();
            ImGui.Text("Active Model(s)");
            ImGui.SameLine();

            ImGui.PushItemWidth(250);
            if (ImGui.BeginCombo("##model_select", selectedModel))
            {
                bool isSelected = "All Models" == selectedModel;
                if (ImGui.Selectable("All Models", isSelected))
                {
                    selectedModel = "All Models";
                    ToggleModel();
                }
                if (isSelected)
                {
                    ImGui.SetItemDefaultFocus();
                }

                foreach (var file in Pipeline.Files)
                {
                    foreach (var model in file.Renderer.Models)
                    {
                        string name = $"{file.Renderer.Name}.{model.Name}";
                        isSelected = name == selectedModel;

                        if (ImGui.Selectable(name, isSelected))
                        {
                            selectedModel = name;
                            ToggleModel();
                        }
                        if (isSelected)
                        {
                            ImGui.SetItemDefaultFocus();
                        }
                    }
                }
                ImGui.EndCombo();
            }
            ImGui.PopItemWidth();
        }
Ejemplo n.º 26
0
        void OnGUI()
        {
            titleContent = new GUIContent("Ease: " + (OptionsFile.instance.time_numbering ? TimelineWindow.frameToTime(key.frame, (float)aData.currentTake.frameRate) + " s" : key.frame.ToString()));

            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            bool updateEasingCurve = false;

            GUIStyle styleBox = new GUIStyle(GUI.skin.button);

            styleBox.normal = GUI.skin.button.active;
            styleBox.hover  = styleBox.normal;
            styleBox.border = GUI.skin.button.border;
            GUILayout.BeginArea(new Rect(5f, 5f, position.width - 10f, position.height - 10f));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("", styleBox, GUILayout.Width(500f), GUILayout.Height(100f)))
            {
                selectedSpeedIndex = (selectedSpeedIndex + 1) % speedValues.Length;
                percent            = waitPercent * -1f;
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();
            int  prevCategory         = category;
            bool updatedSelectedIndex = false;

            if (setCategory(GUILayout.SelectionGrid(category, categories, (position.width >= 715f ? 12 : 6), GUILayout.Width(position.width - 16f))))
            {
                selectedIndex = getSelectedEaseIndex(prevCategory, selectedIndex);
                selectedIndex = getCategoryIndexForEase(selectedIndex);
                if (selectedIndex < 1)
                {
                    selectedIndex        = 1;
                    percent              = waitPercent * -1f;
                    updatedSelectedIndex = true;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);

            GUILayout.BeginVertical(GUILayout.Height(233f));
            if (updatedSelectedIndex || setSelectedIndex(GUILayout.SelectionGrid(selectedIndex, easeTypesFiltered[category].ToArray(), 3)))
            {
                percent           = waitPercent * -1f;
                updateEasingCurve = true;
                if (getSelectedEaseName(category, selectedIndex) == "Custom")
                {
                    isCustomEase = true;
                    if (key.customEase.Count > 0)
                    {
                        curve = key.getCustomEaseCurve();
                    }
                    else
                    {
                        setEasingCurve();
                    }
                }
                else
                {
                    isCustomEase = false;
                }
            }
            GUILayout.EndVertical();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                Ease nease             = (Ease)TimelineWindow.GetEaseIndex(getSelectedEaseIndex(category, selectedIndex));
                bool shouldUpdateCache = false;
                if (isCustomEase)
                {
                    key.setCustomEase(curve);
                    shouldUpdateCache = true;
                }
                if (key.easeType != nease)
                {
                    shouldUpdateCache = true;
                }
                if (shouldUpdateCache)
                {
                    aData.RegisterTakesUndo("Change Ease", false);
                    key.setEaseType(nease);
                    // update cache when modifying varaibles
                    track.updateCache(aData.target);
                    // preview new position
                    aData.currentTake.previewFrame(aData.target, aData.currentTake.selectedFrame);
                }
                this.Close();
            }
            if (GUILayout.Button("Cancel"))
            {
                this.Close();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            // orb texture
            GUI.DrawTexture(new Rect(x_pos, 15f, 80f, 80f), tex_orb);
            // speed label
            GUIStyle styleLabelRight = new GUIStyle(GUI.skin.label);

            styleLabelRight.alignment        = TextAnchor.MiddleRight;
            styleLabelRight.normal.textColor = Color.white;
            EditorGUI.DropShadowLabel(new Rect(475f, 5f, 25f, 25f), speedNames[selectedSpeedIndex], styleLabelRight);
            // draw border
            GUI.color = GUI.skin.window.normal.textColor;
            GUI.DrawTexture(new Rect(0f, 0f, 7f, 110f), EditorGUIUtility.whiteTexture);
            GUI.DrawTexture(new Rect(position.width - 209f, 0f, 208f, 110f), EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            // curve field
            if (updateEasingCurve)
            {
                setEasingCurve();
            }
            else if (!isCustomEase && didChangeCurve())
            {
                isCustomEase  = true;
                selectedIndex = getCategoryIndexForEaseName("Custom");
                if (selectedIndex < 0)
                {
                    category      = 0;
                    selectedIndex = getCategoryIndexForEaseName("Custom");
                }
            }
            curve = EditorGUI.CurveField(new Rect(500f, 5f, 208f, 100f), curve);
        }
Ejemplo n.º 27
0
        void saveChanges()
        {
            if (!TimelineWindow.window)
            {
                return;
            }
            AnimateEditControl aData = TimelineWindow.window.aData;

            if (aData == null)
            {
                return;
            }

            List <GameObject> keepReferences    = new List <GameObject>();
            List <GameObject> replaceReferences = new List <GameObject>();

            for (int i = 0; i < newReference.Count; i++)
            {
                if (actions[i] == 0)
                {
                    continue;
                }
                if (newReference[i] == oldReference[i])
                {
                    continue;
                }
                if (!newReference[i] || !oldReference[i])
                {
                    continue;                                       // skip null values
                }
                else if (actions[i] == 1)
                {
                    keepReferences.Add(newReference[i]);
                    replaceReferences.Add(oldReference[i]);
                }
                else if (actions[i] == 2)
                {
                    keepReferences.Add(oldReference[i]);
                    replaceReferences.Add(newReference[i]);
                }
            }

            if (keepReferences.Count <= 0)
            {
                this.Close();
                return; // return if no changes made
            }
            //TODO: undo "Resolve Duplicates"
            // update references
            List <GameObject> lsFlagToKeep = aData.UpdateDependencies(keepReferences, replaceReferences);

            // reset event track method info
            TimelineWindow.resetIndexMethodInfo();
            TimelineWindow.shouldCheckDependencies = false;
            //aData.shouldCheckDependencies = false;
            // delete replaced references
            int count = 0;

            for (int i = 0; i < replaceReferences.Count; i++)
            {
                if (lsFlagToKeep.Contains(replaceReferences[i]))
                {
                    continue;
                }
                DestroyImmediate(replaceReferences[i]);
                replaceReferences.RemoveAt(i);
                count++;
                i--;
            }
            replaceReferences = new List <GameObject>();

            Debug.Log("Animator: Resolved Duplicate" + (count > 1 ? "s" : "") + ". Deleted " + count + " GameObject" + (count > 1 ? "s" : "") + ".");
            this.Close();
        }
Ejemplo n.º 28
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            GUIStyle padding = new GUIStyle();

            padding.padding = new RectOffset(3, 3, 3, 3);
            GUILayout.BeginVertical(padding);
            // show list of items
            showItems();

            GUILayout.Space(3f);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("All", GUILayout.Width(50f)))
            {
                for (int i = 0; i < gameObjsSelected.Count; i++)
                {
                    if (gameObjsSelected[i] == false)
                    {
                        gameObjsSelected[i] = true;
                    }
                }
            }
            if (GUILayout.Button("None", GUILayout.Width(50f)))
            {
                for (int i = 0; i < gameObjsSelected.Count; i++)
                {
                    if (gameObjsSelected[i] == true)
                    {
                        gameObjsSelected[i] = false;
                    }
                }
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Export...", GUILayout.Width(80f)))
            {
                bool shouldExit    = false;
                bool performExport = true;
                if (string.IsNullOrEmpty(EditorSceneManager.GetActiveScene().name))
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("Save Current Scene", "The current scene must be saved before an export is performed.", "Save Current Scene", "Cancel"))
                    {
                        EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
                        UnityEditor.EditorUtility.DisplayDialog("Performing Export...", "The current scene has been saved. Now performing export.", "Continue");
                    }
                    else
                    {
                        performExport = false;
                    }
                }
                if (performExport)
                {
                    if (saveSelectedItemsToScene())
                    {
                        shouldExit = true;
                    }
                }
                if (shouldExit)
                {
                    this.Close();
                    GUIUtility.ExitGUI();
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
Ejemplo n.º 29
0
        void OnGUI()
        {
            TimelineWindow.loadSkin(ref skin, ref cachedSkinName, position);
            if (aData == null)
            {
                TimelineWindow.MessageBox("Animator requires an Animate component in your scene. Launch Animator to add the component.", TimelineWindow.MessageBoxType.Warning);
                return;
            }

            if (mTrack == null)
            {
                return;
            }

            Renderer render = mTrack.GetTarget(aData.target) as Renderer;

            if (!render)
            {
                TimelineWindow.MessageBox("Assign a Renderer to the track first.", TimelineWindow.MessageBoxType.Warning);
                return;
            }

            //select material
            Material[] mats = render.sharedMaterials;

            string[] matNames = new string[mats.Length];
            int[]    matInds  = new int[mats.Length];
            for (int i = 0; i < mats.Length; i++)
            {
                matNames[i] = mats[i].name;
                matInds[i]  = i;
            }

            //grab track info
            int      matInd         = Mathf.Clamp(mTrack.materialIndex, 0, mats.Length - 1);
            Material matOverride    = mTrack.materialOverride;
            string   shaderProperty = mTrack.property;

            //material select
            matInd = EditorGUILayout.IntPopup("Material", matInd, matNames, matInds);

            //material override select
            matOverride = EditorGUILayout.ObjectField("Material Override", matOverride, typeof(Material), false) as Material;

            Material mat = matOverride ? matOverride : mats[matInd];

            //grab material info
            string[] shaderPropertyNames, shaderPropertyDetails;
            MaterialTrack.ValueType[] shaderPropertyTypes;
            int[] shaderPropertyInds;
            GetPropertyInfos(mat, out shaderPropertyNames, out shaderPropertyDetails, out shaderPropertyTypes, out shaderPropertyInds);

            int shaderPropertyInd = -1;

            MaterialTrack.ValueType shaderPropertyType = mTrack.propertyType;

            for (int i = 0; i < shaderPropertyNames.Length; i++)
            {
                if (shaderProperty == shaderPropertyNames[i])
                {
                    shaderPropertyInd = i;

                    //special case for texture offset and scale
                    if (shaderPropertyTypes[i] == MaterialTrack.ValueType.TexEnv && i + 2 < shaderPropertyNames.Length)
                    {
                        if (shaderPropertyType == shaderPropertyTypes[i + 1])
                        {
                            shaderPropertyInd += 1;
                        }
                        else if (shaderPropertyType == shaderPropertyTypes[i + 2])
                        {
                            shaderPropertyInd += 2;
                        }
                    }
                    break;
                }
            }

            if (shaderPropertyInd == -1)
            {
                shaderPropertyInd = 0;
            }

            EditorUtility.DrawSeparator();

            //shader property select
            shaderPropertyInd = EditorGUILayout.IntPopup("Property", shaderPropertyInd, shaderPropertyDetails, shaderPropertyInds);

            shaderProperty     = shaderPropertyNames[shaderPropertyInd];
            shaderPropertyType = shaderPropertyTypes[shaderPropertyInd];

            //check for change
            if (mTrack.materialIndex != matInd || mTrack.materialOverride != matOverride || mTrack.property != shaderProperty || mTrack.propertyType != shaderPropertyType)
            {
                aData.RegisterTakesUndo("Material Track Property Change", false);

                mTrack.materialIndex    = matInd;
                mTrack.materialOverride = matOverride;
                mTrack.property         = shaderProperty;
                mTrack.propertyType     = shaderPropertyType;
            }
        }
Ejemplo n.º 30
0
        void showGameObject(int i, int level)
        {
            GUILayout.BeginHorizontal(GUILayout.Height(height_gameobject));
            if (gameObjsSelected[i] == null)
            {
                GUI.enabled = false;
                GUILayout.Toggle(true, "", GUILayout.Width(width_toggle));
            }
            else
            {
                gameObjsSelected[i] = GUILayout.Toggle((bool)gameObjsSelected[i], "", GUILayout.Width(width_toggle));
            }
            // indent
            GUILayout.Space(width_indent * level);

            if (gameObjsFoldout[i] != null)
            {
                GUI.enabled = true;
                // foldout
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset - 1f);
                if (GUILayout.Button("", "label", GUILayout.Width(15f)))
                {
                    gameObjsFoldout[i] = !gameObjsFoldout[i];
                }
                GUI.DrawTexture(GUILayoutUtility.GetLastRect(), ((bool)gameObjsFoldout[i] ? GUI.skin.GetStyle("GroupElementFoldout").normal.background : GUI.skin.GetStyle("GroupElementFoldout").active.background));
                GUILayout.EndVertical();
                // toggle children
                //if(gameObjsSelected[i] != null) {
                if (gameObjsSelected[i] == null)
                {
                    GUI.enabled = false;
                }
                GUILayout.BeginVertical();
                GUILayout.Space(height_label_offset + 1f);
                if (GUILayout.Button("", GUILayout.Width(13f), GUILayout.Height(15f)))
                {
                    if (gameObjsSelected[i] != null)
                    {
                        gameObjsSelected[i] = !gameObjsSelected[i];
                        setAllChildrenSelection((bool)gameObjsSelected[i], i, gameObjsDepth[i]);
                    }
                }
                Rect rectSelectAllTexture = GUILayoutUtility.GetLastRect();
                GUILayout.EndVertical();

                rectSelectAllTexture.x     += 3f;
                rectSelectAllTexture.y     += 4f;
                rectSelectAllTexture.width  = 7f;
                rectSelectAllTexture.height = 8f;
                if (!GUI.enabled)
                {
                    GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f);
                }
                GUI.DrawTexture(rectSelectAllTexture, TimelineWindow.getSkinTextureStyleState("select_all").background);
                GUI.color = Color.white;
                //}
            }
            else
            {
                GUILayout.Space(15f);
            }

            GUILayout.BeginVertical();
            GUILayout.Space(height_label_offset);
            if (gameObjsFoldout[i] != null)
            {
                GUILayout.Label(gameObjs[i].name);
            }
            else
            {
                GUILayout.Label(new GUIContent(gameObjs[i].name, EditorGUIUtility.ObjectContent(null, typeof(GameObject)).image), GUILayout.Height(19f));
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            if (!GUI.enabled)
            {
                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();
        }