Exemplo n.º 1
0
        void ShowRecorderListMenu()
        {
            var menu = new GenericMenu();

            menu.AddItem(Styles.SaveRecorderListLabel, false, () =>
            {
                var path = EditorUtility.SaveFilePanelInProject("Save Preset", "RecorderSettingPreset.asset", "asset", "");

                if (path.Length != 0)
                {
                    RecorderControllerSettingsPreset.SaveAtPath(m_ControllerSettings, path);
                }
            });

            var presets = AssetDatabase.FindAssets("t:" + typeof(RecorderControllerSettingsPreset).Name);

            if (presets.Length > 0)
            {
                foreach (var preset in presets)
                {
                    var path     = AssetDatabase.GUIDToAssetPath(preset);
                    var fileName = Path.GetFileNameWithoutExtension(path);
                    menu.AddItem(new GUIContent("Load Recorder List/" + fileName), false, data => { ApplyPreset((string)data); }, path);
                }
            }
            else
            {
                menu.AddDisabledItem(Styles.LoadRecorderListLabel);
            }

            var items = m_RecordingListItem.items.ToArray();

            if (items.Length > 0)
            {
                menu.AddItem(Styles.ClearRecorderListLabel, false, () =>
                {
                    if (EditorUtility.DisplayDialog("Clear Recoder List?", "All recorder will be deleted. Proceed?", "Delete Recorders", "Cancel"))
                    {
                        foreach (var item in items)
                        {
                            if (item.editor != null)
                            {
                                DestroyImmediate(item.editor);
                            }

                            DeleteRecorder(item, false);
                        }

                        ReloadRecordings();
                    }
                });
            }
            else
            {
                menu.AddDisabledItem(Styles.ClearRecorderListLabel);
            }

            menu.ShowAsContext();
        }
Exemplo n.º 2
0
        void ShowRecorderListMenu()
        {
            var menu = new GenericMenu();

            menu.AddItem(Styles.SaveRecorderListLabel, false, () =>
            {
                var path = EditorUtility.SaveFilePanelInProject("Save Preset", "RecorderSettingPreset.asset", "asset", "");

                if (path.Length != 0)
                {
                    RecorderControllerSettingsPreset.SaveAtPath(m_ControllerSettings, path);
                }
            });

            var presets = AssetDatabase.FindAssets("t:" + typeof(RecorderControllerSettingsPreset).Name);

            if (presets.Length > 0)
            {
                foreach (var preset in presets)
                {
                    var path     = AssetDatabase.GUIDToAssetPath(preset);
                    var fileName = Path.GetFileNameWithoutExtension(path);
                    menu.AddItem(new GUIContent("Load Recorder List/" + fileName), false, data => { ApplyPreset((string)data); }, path);
                }
            }
            else
            {
                menu.AddDisabledItem(Styles.LoadRecorderListLabel);
            }

            var items = m_RecordingListItem.items.ToArray();

            if (items.Length > 0)
            {
                menu.AddItem(Styles.ClearRecorderListLabel, false, () =>
                {
                    Undo.IncrementCurrentGroup();
                    Undo.SetCurrentGroupName("Clear Recorder List");
                    var undoGroupIndex = Undo.GetCurrentGroup();
                    foreach (var item in items)
                    {
                        if (item.editor != null)
                        {
                            DestroyImmediate(item.editor);
                        }

                        DeleteRecorder(item);
                    }
                    Undo.CollapseUndoOperations(undoGroupIndex);
                    ReloadRecordings();
                });
            }
            else
            {
                menu.AddDisabledItem(Styles.ClearRecorderListLabel);
            }

            menu.ShowAsContext();
        }