GetActiveFolderPath() static private method

static private GetActiveFolderPath ( ) : string
return string
示例#1
0
 internal static int[] PasteFolders()
 {
     if (performedAction == PerformedAction.Cut)
     {
         return(PasteFoldersAfterCut(ProjectWindowUtil.GetActiveFolderPath()));
     }
     else
     {
         return(PasteFoldersAfterCopy(ProjectWindowUtil.GetActiveFolderPath()));
     }
 }
        internal void CreateBrush()
        {
            ObjectSelector.get.Show(null, typeof(Texture2D), null, false, null,
                                    selection =>
            {
                if (selection == null)
                {
                    return;
                }

                var brushName = AssetDatabase.GenerateUniqueAssetPath(Path.Combine(ProjectWindowUtil.GetActiveFolderPath(), "NewBrush.brush"));
                var newBrush  = Brush.CreateInstance((Texture2D)selection, AnimationCurve.Linear(0, 0, 1, 1), Brush.kMaxRadiusScale, false);
                AssetDatabase.CreateAsset(newBrush, brushName);
                LoadBrushes();
            }, null);
        }
示例#3
0
        static bool CreateAnimation(GameObject gameObject, Object[] frames, ShowFileDialogDelegate saveFileDialog)
        {
            saveFileDialog = saveFileDialog ?? EditorUtility.SaveFilePanelInProject;

            // Use same name compare as when we sort in the backend: See AssetDatabase.cpp: SortChildren
            System.Array.Sort(frames, (a, b) => EditorUtility.NaturalCompare(a.name, b.name));

            Animator animator = AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject)
                ? AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform)
                : null;

            bool createSuccess = animator != null;

            if (animator != null)
            {
                // Go forward with presenting user a save clip dialog
                string message          = string.Format(SpriteUtilityStrings.saveAnimDialogMessage.text, gameObject.name);
                string newClipDirectory = ProjectWindowUtil.GetActiveFolderPath();
                string newClipPath      = saveFileDialog(SpriteUtilityStrings.saveAnimDialogTitle.text, SpriteUtilityStrings.saveAnimDialogName.text, "anim", message, newClipDirectory);

                if (string.IsNullOrEmpty(newClipPath))
                {
                    Undo.ClearUndo(animator);
                    Object.DestroyImmediate(animator);
                    return(false);
                }
                else
                {
                    AnimationClip newClip = AnimationWindowUtility.CreateNewClipAtPath(newClipPath);
                    if (newClip != null)
                    {
                        AddSpriteAnimationToClip(newClip, frames);
                        createSuccess = AnimationWindowUtility.AddClipToAnimatorComponent(animator, newClip);
                    }
                }
            }

            if (createSuccess == false)
            {
                Debug.LogError(SpriteUtilityStrings.failedToCreateAnimationError.text);
            }

            return(createSuccess);
        }
示例#4
0
        internal static void CreateLayer(MenuCommand item)
        {
            ObjectSelector.get.Show(null, typeof(Texture2D), null, false, null,
                                    selection =>
            {
                if (selection == null)
                {
                    return;
                }

                var layerName = AssetDatabase.GenerateUniqueAssetPath(
                    Path.Combine(ProjectWindowUtil.GetActiveFolderPath(), "NewLayer.terrainlayer"));
                var terrain = (Terrain)item.context;
                var layer   = new TerrainLayer();
                AssetDatabase.CreateAsset(layer, layerName);
                TerrainLayerUtility.AddTerrainLayer(terrain, layer);
                layer.diffuseTexture = (Texture2D)selection;
            }, null);
        }
示例#5
0
        private static bool CreateAnimation(GameObject gameObject, UnityEngine.Object[] frames, SpriteUtility.ShowFileDialogDelegate saveFileDialog)
        {
            SpriteUtility.ShowFileDialogDelegate arg_26_0;
            if ((arg_26_0 = saveFileDialog) == null)
            {
                if (SpriteUtility.< > f__mg$cache1 == null)
                {
                    SpriteUtility.< > f__mg$cache1 = new SpriteUtility.ShowFileDialogDelegate(EditorUtility.SaveFilePanelInProject);
                }
                arg_26_0 = SpriteUtility.< > f__mg$cache1;
            }
            saveFileDialog = arg_26_0;
            Array.Sort <UnityEngine.Object>(frames, (UnityEngine.Object a, UnityEngine.Object b) => EditorUtility.NaturalCompare(a.name, b.name));
            Animator animator = (!AnimationWindowUtility.EnsureActiveAnimationPlayer(gameObject)) ? null : AnimationWindowUtility.GetClosestAnimatorInParents(gameObject.transform);
            bool     flag     = animator != null;
            bool     result;

            if (animator != null)
            {
                string message          = string.Format(SpriteUtility.SpriteUtilityStrings.saveAnimDialogMessage.text, gameObject.name);
                string activeFolderPath = ProjectWindowUtil.GetActiveFolderPath();
                string text             = saveFileDialog(SpriteUtility.SpriteUtilityStrings.saveAnimDialogTitle.text, SpriteUtility.SpriteUtilityStrings.saveAnimDialogName.text, "anim", message, activeFolderPath);
                if (string.IsNullOrEmpty(text))
                {
                    UnityEngine.Object.DestroyImmediate(animator);
                    result = false;
                    return(result);
                }
                AnimationClip animationClip = AnimationWindowUtility.CreateNewClipAtPath(text);
                if (animationClip != null)
                {
                    SpriteUtility.AddSpriteAnimationToClip(animationClip, frames);
                    flag = AnimationWindowUtility.AddClipToAnimatorComponent(animator, animationClip);
                }
            }
            if (!flag)
            {
                Debug.LogError(SpriteUtility.SpriteUtilityStrings.failedToCreateAnimationError.text);
            }
            result = flag;
            return(result);
        }
示例#6
0
        internal static void PasteSelectedAssets(bool isTwoColumnView)
        {
            string targetPath;

            // If we are using OneColumnLayout rely on object selection, otherwise rely on active folder
            if (!isTwoColumnView && Selection.objects.Length == 1)
            {
                targetPath = AssetDatabase.GetAssetPath(Selection.activeObject);

                // If selected object is folder, make sure we paste into it.
                if (AssetDatabase.IsValidFolder(targetPath))
                {
                    targetPath += "/";
                }
                else
                {
                    targetPath = Path.GetDirectoryName(targetPath);
                }
            }
            else
            {
                targetPath = ProjectWindowUtil.GetActiveFolderPath();
            }

            switch (performedAction)
            {
            case PerformedAction.Copy:
                Selection.objects = PasteCopiedAssets(targetPath).ToArray();
                break;

            case PerformedAction.Cut:
                Selection.objects = PasteCutAssets(targetPath).ToArray();
                performedAction   = PerformedAction.None;
                break;
            }
        }
示例#7
0
            public override void OnInspectorGUI()
            {
                serializedObject.Update();

                serializedObject.ApplyModifiedProperties();

                EditorGUILayout.PropertyField(m_PreloadedShaders, true);

                EditorGUILayout.Space();
                GUILayout.Label(
                    string.Format("Currently tracked: {0} shaders {1} total variants",
                                  ShaderUtil.GetCurrentShaderVariantCollectionShaderCount(), ShaderUtil.GetCurrentShaderVariantCollectionVariantCount()
                                  )
                    );

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(Styles.shaderPreloadSave, EditorStyles.miniButton))
                {
                    string message   = "Save shader variant collection";
                    string assetPath = EditorUtility.SaveFilePanelInProject("Save Shader Variant Collection", "NewShaderVariants", "shadervariants", message, ProjectWindowUtil.GetActiveFolderPath());
                    if (!string.IsNullOrEmpty(assetPath))
                    {
                        ShaderUtil.SaveCurrentShaderVariantCollection(assetPath);
                    }
                    GUIUtility.ExitGUI();
                }
                if (GUILayout.Button(Styles.shaderPreloadClear, EditorStyles.miniButton))
                {
                    ShaderUtil.ClearCurrentShaderVariantCollection();
                }
                EditorGUILayout.EndHorizontal();

                serializedObject.ApplyModifiedProperties();
            }
示例#8
0
 private void ShaderPreloadGUI()
 {
     EditorGUILayout.Space();
     GUILayout.Label(GraphicsSettingsInspector.Styles.shaderPreloadSettings, EditorStyles.boldLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_PreloadedShaders, true, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     GUILayout.Label(string.Format("Currently tracked: {0} shaders {1} total variants", (object)ShaderUtil.GetCurrentShaderVariantCollectionShaderCount(), (object)ShaderUtil.GetCurrentShaderVariantCollectionVariantCount()));
     EditorGUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     if (GUILayout.Button(GraphicsSettingsInspector.Styles.shaderPreloadSave, EditorStyles.miniButton, new GUILayoutOption[0]))
     {
         string path = EditorUtility.SaveFilePanelInProject("Save Shader Variant Collection", "NewShaderVariants", "shadervariants", "Save shader variant collection", ProjectWindowUtil.GetActiveFolderPath());
         if (!string.IsNullOrEmpty(path))
         {
             ShaderUtil.SaveCurrentShaderVariantCollection(path);
         }
         GUIUtility.ExitGUI();
     }
     if (GUILayout.Button(GraphicsSettingsInspector.Styles.shaderPreloadClear, EditorStyles.miniButton, new GUILayoutOption[0]))
     {
         ShaderUtil.ClearCurrentShaderVariantCollection();
     }
     EditorGUILayout.EndHorizontal();
 }
        private AnimationClip CreateNewClip()
        {
            bool   flag    = this.animatedObject.GetComponent <Animator>() != null || this.animatedObject.GetComponent <Animation>() == null;
            string message = string.Format("Create a new animation for the game object '{0}':", this.animatedObject.name);
            string text    = EditorUtility.SaveFilePanelInProject("Create New Animation", "New Animation", "anim", message, ProjectWindowUtil.GetActiveFolderPath());

            if (text == string.Empty)
            {
                return(null);
            }
            AnimationClip animationClip = AnimationSelection.AllocateAndSetupClip(flag);

            AssetDatabase.CreateAsset(animationClip, text);
            this.m_AnimationWindow.EndAnimationMode();
            if (flag)
            {
                return(AnimationSelection.AddClipToAnimatorComponent(this.animatedObject, animationClip));
            }
            return(this.AddClipToAnimationComponent(animationClip));
        }
示例#10
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.ApplyModifiedProperties();
     EditorGUILayout.PropertyField(this.m_PreloadedShaders, true, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     GUILayout.Label(string.Format("Currently tracked: {0} shaders {1} total variants", ShaderUtil.GetCurrentShaderVariantCollectionShaderCount(), ShaderUtil.GetCurrentShaderVariantCollectionVariantCount()), new GUILayoutOption[0]);
     EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     if (GUILayout.Button(GraphicsSettingsWindow.ShaderPreloadEditor.Styles.shaderPreloadSave, EditorStyles.miniButton, new GUILayoutOption[0]))
     {
         string message = "Save shader variant collection";
         string text    = EditorUtility.SaveFilePanelInProject("Save Shader Variant Collection", "NewShaderVariants", "shadervariants", message, ProjectWindowUtil.GetActiveFolderPath());
         if (!string.IsNullOrEmpty(text))
         {
             ShaderUtil.SaveCurrentShaderVariantCollection(text);
         }
         GUIUtility.ExitGUI();
     }
     if (GUILayout.Button(GraphicsSettingsWindow.ShaderPreloadEditor.Styles.shaderPreloadClear, EditorStyles.miniButton, new GUILayoutOption[0]))
     {
         ShaderUtil.ClearCurrentShaderVariantCollection();
     }
     EditorGUILayout.EndHorizontal();
     base.serializedObject.ApplyModifiedProperties();
 }