Exemplo n.º 1
0
        private void DrawToolbar()
        {
            if (m_IsMultiEditing)
            {
                EditorGUILayout.HelpBox(s_Styles.disabledEditMessage, MessageType.Info);
            }

            EditorGUI.BeginDisabled(m_IsMultiEditing);
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditMode.DoInspectorToolbar(s_Styles.sceneViewEditModes, s_Styles.toolContents, GetBounds, this);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Tools box
            GUILayout.BeginVertical(EditorStyles.helpBox);
            string helpText = Styles.baseSceneEditingToolText;

            if (sceneViewEditing)
            {
                int index = ArrayUtility.IndexOf(s_Styles.sceneViewEditModes, EditMode.editMode);
                if (index >= 0)
                {
                    helpText = s_Styles.toolNames[index].text;
                }
            }

            GUILayout.Label(helpText, s_Styles.richTextMiniLabel);
            GUILayout.EndVertical();

            // Editing mode toolbar
            if (sceneViewEditing)
            {
                switch (EditMode.editMode)
                {
                case EditMode.SceneViewEditMode.LineRendererEdit:
                    DrawEditPointTools();
                    break;

                case EditMode.SceneViewEditMode.LineRendererCreate:
                    CreatePointTools();
                    break;
                }
            }
            if (!sceneViewEditing)
            {
                EditorGUI.BeginChangeCheck();
                showSimplifyPreview = EditorGUILayout.Toggle(s_Styles.simplifyPreview, showSimplifyPreview);
                EditorGUILayout.BeginHorizontal();
                simplifyTolerance = Mathf.Max(0, EditorGUILayout.FloatField(s_Styles.tolerance, simplifyTolerance));
                if (GUILayout.Button(s_Styles.simplify, EditorStyles.miniButton))
                {
                    SimplifyPoints();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    ResetSimplifyPreview();
                }

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }
            EditorGUILayout.Space();
            EditorGUI.EndDisabled();
        }
        private void AnimationSplitTable()
        {
            if (this.m_ClipList == null)
            {
                this.m_ClipList = new ReorderableList(new List <AnimationClipInfoProperties>(), typeof(string), false, true, true, true);
                this.m_ClipList.onAddCallback       = new ReorderableList.AddCallbackDelegate(this.AddClipInList);
                this.m_ClipList.onSelectCallback    = new ReorderableList.SelectCallbackDelegate(this.SelectClipInList);
                this.m_ClipList.onRemoveCallback    = new ReorderableList.RemoveCallbackDelegate(this.RemoveClipInList);
                this.m_ClipList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawClipElement);
                this.m_ClipList.drawHeaderCallback  = new ReorderableList.HeaderCallbackDelegate(this.DrawClipHeader);
                this.m_ClipList.elementHeight       = 16f;
                this.UpdateList();
                this.m_ClipList.index = this.selectedClipIndex;
            }
            this.m_ClipList.DoLayoutList();
            EditorGUI.BeginChangeCheck();
            AnimationClipInfoProperties selectedClipInfo = this.GetSelectedClipInfo();

            if (selectedClipInfo != null)
            {
                if ((this.m_AnimationClipEditor != null) && (this.selectedClipIndex != -1))
                {
                    GUILayout.Space(5f);
                    AnimationClip target = this.m_AnimationClipEditor.target as AnimationClip;
                    if (!target.legacy)
                    {
                        this.GetSelectedClipInfo().AssignToPreviewClip(target);
                    }
                    TakeInfo[] importedTakeInfos = this.singleImporter.importedTakeInfos;
                    string[]   array             = new string[importedTakeInfos.Length];
                    for (int i = 0; i < importedTakeInfos.Length; i++)
                    {
                        array[i] = importedTakeInfos[i].name;
                    }
                    EditorGUI.BeginChangeCheck();
                    string name  = selectedClipInfo.name;
                    int    index = ArrayUtility.IndexOf <string>(array, selectedClipInfo.takeName);
                    this.m_AnimationClipEditor.takeNames = array;
                    this.m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf <string>(array, selectedClipInfo.takeName);
                    this.m_AnimationClipEditor.DrawHeader();
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selectedClipInfo.name != name)
                        {
                            this.TransferDefaultClipsToCustomClips();
                            PatchImportSettingRecycleID.Patch(base.serializedObject, 0x4a, name, selectedClipInfo.name);
                        }
                        int takeIndex = this.m_AnimationClipEditor.takeIndex;
                        if ((takeIndex != -1) && (takeIndex != index))
                        {
                            selectedClipInfo.name = this.MakeUniqueClipName(array[takeIndex], -1);
                            this.SetupTakeNameAndFrames(selectedClipInfo, importedTakeInfos[takeIndex]);
                            GUIUtility.keyboardControl = 0;
                            this.SelectClip(this.selectedClipIndex);
                            target = this.m_AnimationClipEditor.target as AnimationClip;
                        }
                    }
                    this.m_AnimationClipEditor.OnInspectorGUI();
                    if (!target.legacy)
                    {
                        this.GetSelectedClipInfo().ExtractFromPreviewClip(target);
                    }
                }
                if (EditorGUI.EndChangeCheck())
                {
                    this.TransferDefaultClipsToCustomClips();
                }
            }
        }
        void AnimationSplitTable()
        {
            if (m_ClipList == null)
            {
                m_ClipList = new ReorderableList(new List <AnimationClipInfoProperties>(), typeof(string), false, true, true, true);
                m_ClipList.onAddCallback       = AddClipInList;
                m_ClipList.onSelectCallback    = SelectClipInList;
                m_ClipList.onRemoveCallback    = RemoveClipInList;
                m_ClipList.drawElementCallback = DrawClipElement;
                m_ClipList.drawHeaderCallback  = DrawClipHeader;
                m_ClipList.elementHeight       = 16;
                UpdateList();
                m_ClipList.index = selectedClipIndex;
            }
            m_ClipList.DoLayoutList();

            EditorGUI.BeginChangeCheck();

            // Show selected clip info
            {
                AnimationClipInfoProperties clip = GetSelectedClipInfo();
                if (clip == null)
                {
                    return;
                }

                if (m_AnimationClipEditor != null && selectedClipIndex != -1)
                {
                    GUILayout.Space(5);

                    AnimationClip actualClip = m_AnimationClipEditor.target as AnimationClip;

                    if (!actualClip.legacy)
                    {
                        GetSelectedClipInfo().AssignToPreviewClip(actualClip);
                    }

                    TakeInfo[] importedTakeInfos = singleImporter.importedTakeInfos;
                    string[]   takeNames         = new string[importedTakeInfos.Length];
                    for (int i = 0; i < importedTakeInfos.Length; i++)
                    {
                        takeNames[i] = importedTakeInfos[i].name;
                    }

                    EditorGUI.BeginChangeCheck();
                    string currentName = clip.name;
                    int    takeIndex   = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.takeNames = takeNames;
                    m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.DrawHeader();

                    if (EditorGUI.EndChangeCheck())
                    {
                        // We renamed the clip name, try to maintain the localIdentifierInFile so we don't lose any data.
                        if (clip.name != currentName)
                        {
                            TransferDefaultClipsToCustomClips();
                            PatchImportSettingRecycleID.Patch(serializedObject, 74, currentName, clip.name);
                        }

                        int newTakeIndex = m_AnimationClipEditor.takeIndex;
                        if (newTakeIndex != -1 && newTakeIndex != takeIndex)
                        {
                            clip.name = MakeUniqueClipName(takeNames[newTakeIndex]);
                            SetupTakeNameAndFrames(clip, importedTakeInfos[newTakeIndex]);
                            GUIUtility.keyboardControl = 0;
                            SelectClip(selectedClipIndex);

                            // actualClip has been changed by SelectClip
                            actualClip = m_AnimationClipEditor.target as AnimationClip;
                        }
                    }

                    m_AnimationClipEditor.OnInspectorGUI();

                    AvatarMaskSettings(GetSelectedClipInfo());

                    if (!actualClip.legacy)
                    {
                        GetSelectedClipInfo().ExtractFromPreviewClip(actualClip);
                    }
                }
            }

            if (EditorGUI.EndChangeCheck() || m_AnimationClipEditor.needsToGenerateClipInfo)
            {
                TransferDefaultClipsToCustomClips();
                m_AnimationClipEditor.needsToGenerateClipInfo = false;
            }
        }
Exemplo n.º 4
0
        private void ReadPreferences()
        {
            m_ScriptEditorPath.str = CodeEditor.Editor.EditorInstallation.Path;

            m_ExternalEditorSupportsUnityProj = EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false);
            m_ImageAppPath.str = EditorPrefs.GetString("kImagesDefaultApp");

            m_ScriptApps         = BuildAppPathList(m_ScriptEditorPath, kRecentScriptAppsKey, "internal");
            m_ScriptAppsEditions = new string[m_ScriptApps.Length];

            var foundScriptEditorPaths = CodeEditor.Editor.GetFoundScriptEditorPaths();

            foreach (var scriptEditorPath in foundScriptEditorPaths.Keys)
            {
                ArrayUtility.Add(ref m_ScriptApps, scriptEditorPath);
                ArrayUtility.Add(ref m_ScriptAppsEditions, null);
            }

            m_ImageApps = BuildAppPathList(m_ImageAppPath, kRecentImageAppsKey, "");

            m_ScriptAppDisplayNames = BuildFriendlyAppNameList(m_ScriptApps, m_ScriptAppsEditions, foundScriptEditorPaths,
                                                               "Open by file extension");

            m_ImageAppDisplayNames = BuildFriendlyAppNameList(m_ImageApps, null, null,
                                                              L10n.Tr("Open by file extension"));

            m_DiffTools = InternalEditorUtility.GetAvailableDiffTools();

            // only show warning if has team license
            if ((m_DiffTools == null || m_DiffTools.Length == 0) && InternalEditorUtility.HasTeamLicense())
            {
                m_noDiffToolsMessage = InternalEditorUtility.GetNoDiffToolsDetectedMessage();
            }

            string diffTool = EditorPrefs.GetString("kDiffsDefaultApp");

            m_DiffToolIndex = ArrayUtility.IndexOf(m_DiffTools, diffTool);
            if (m_DiffToolIndex == -1)
            {
                m_DiffToolIndex = 0;
            }

            m_AutoRefresh = EditorPrefs.GetBool("kAutoRefresh");

            m_ReopenLastUsedProjectOnStartup = EditorPrefs.GetBool("ReopenLastUsedProjectOnStartup");

            m_UseOSColorPicker            = EditorPrefs.GetBool("UseOSColorPicker");
            m_EnableEditorAnalytics       = EditorPrefs.GetBool("EnableEditorAnalytics", true);
            m_ShowAssetStoreSearchHits    = EditorPrefs.GetBool("ShowAssetStoreSearchHits", true);
            m_VerifySavingAssets          = EditorPrefs.GetBool("VerifySavingAssets", false);
            m_ScriptCompilationDuringPlay = (ScriptChangesDuringPlayOptions)EditorPrefs.GetInt("ScriptCompilationDuringPlay", 0);
            m_DeveloperMode = Unsupported.IsDeveloperMode();

            m_GICacheSettings.m_EnableCustomPath = EditorPrefs.GetBool("GICacheEnableCustomPath");
            m_GICacheSettings.m_CachePath        = EditorPrefs.GetString("GICacheFolder");
            m_GICacheSettings.m_MaximumSize      = EditorPrefs.GetInt("GICacheMaximumSizeGB", 10);
            m_GICacheSettings.m_CompressionLevel = EditorPrefs.GetInt("GICacheCompressionLevel");

            m_SpriteAtlasCacheSize = EditorPrefs.GetInt("SpritePackerCacheMaximumSizeGB");

            m_AllowAttachedDebuggingOfEditor = EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", true);
            m_EnableEditorLocalization       = EditorPrefs.GetBool("Editor.kEnableEditorLocalization", true);
            m_SelectedLanguage           = EditorPrefs.GetString("Editor.kEditorLocale", LocalizationDatabase.GetDefaultEditorLanguage().ToString());
            m_AllowAlphaNumericHierarchy = EditorPrefs.GetBool("AllowAlphaNumericHierarchy", false);
            m_EnableCodeCoverage         = EditorPrefs.GetBool("CodeCoverageEnabled", false);

            m_CompressAssetsOnImport = Unsupported.GetApplicationSettingCompressAssetsOnImport();
            m_GpuDevice = EditorPrefs.GetString("GpuDeviceName");

            foreach (IPreferenceWindowExtension extension in prefWinExtensions)
            {
                extension.ReadPreferences();
            }
        }
        void AnimationSplitTable()
        {
            m_ClipList.DoLayoutList();

            EditorGUI.BeginChangeCheck();

            // Show selected clip info
            {
                AnimationClipInfoProperties clip = GetSelectedClipInfo();
                if (clip == null)
                {
                    return;
                }

                if (m_AnimationClipEditor != null)
                {
                    GUILayout.Space(5);

                    AnimationClip actualClip = m_AnimationClipEditor.target as AnimationClip;

                    if (!actualClip.legacy)
                    {
                        clip.AssignToPreviewClip(actualClip);
                    }

                    TakeInfo[] importedTakeInfos = singleImporter.importedTakeInfos;
                    string[]   takeNames         = new string[importedTakeInfos.Length];
                    for (int i = 0; i < importedTakeInfos.Length; i++)
                    {
                        takeNames[i] = importedTakeInfos[i].name;
                    }

                    EditorGUI.BeginChangeCheck();
                    string currentName = clip.name;
                    int    takeIndex   = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.takeNames = takeNames;
                    m_AnimationClipEditor.takeIndex = ArrayUtility.IndexOf(takeNames, clip.takeName);
                    m_AnimationClipEditor.DrawHeader();

                    if (EditorGUI.EndChangeCheck())
                    {
                        clip.name = clip.name.Trim();
                        if (clip.name == String.Empty)
                        {
                            clip.name = currentName;
                        }
                        // We renamed the clip name, try to maintain the localIdentifierInFile so we don't lose any data.
                        if (clip.name != currentName)
                        {
                            var newName = clip.name;
                            clip.name = currentName;
                            clip.name = MakeUniqueClipName(newName);

                            TransferDefaultClipsToCustomClips();
                            UnityType animationClipType = UnityType.FindTypeByName("AnimationClip");
                            ImportSettingInternalID.Rename(serializedObject, animationClipType, currentName, clip.name);
                        }

                        int newTakeIndex = m_AnimationClipEditor.takeIndex;
                        if (newTakeIndex != -1 && newTakeIndex != takeIndex)
                        {
                            clip.name = MakeUniqueClipName(takeNames[newTakeIndex]);
                            SetupTakeNameAndFrames(clip, importedTakeInfos[newTakeIndex]);
                            GUIUtility.keyboardControl = 0;
                            SelectClip(m_ClipList.index);

                            // actualClip has been changed by SelectClip
                            actualClip = m_AnimationClipEditor.target as AnimationClip;
                        }
                    }

                    m_AnimationClipEditor.OnInspectorGUI();

                    AvatarMaskSettings(clip);

                    if (!actualClip.legacy)
                    {
                        clip.ExtractFromPreviewClip(actualClip);
                    }

                    if (EditorGUI.EndChangeCheck() || m_AnimationClipEditor.needsToGenerateClipInfo)
                    {
                        TransferDefaultClipsToCustomClips();
                        m_AnimationClipEditor.needsToGenerateClipInfo = false;
                    }
                }
            }
        }