StartNameEditingIfProjectWindowExists() public static method

public static StartNameEditingIfProjectWindowExists ( int instanceID, UnityEditor endAction, string pathName, Texture2D icon, string resourceFile ) : void
instanceID int
endAction UnityEditor
pathName string
icon UnityEngine.Texture2D
resourceFile string
return void
 public static void CreatePrefab()
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreatePrefab>(), "New Prefab.prefab", EditorGUIUtility.IconContent("Prefab Icon").image as Texture2D, null);
 }
 public static void CreateFolder()
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateFolder>(), "New Folder", EditorGUIUtility.IconContent(EditorResourcesUtility.emptyFolderIconName).image as Texture2D, null);
 }
 public static void CreateScene()
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateScene>(), "New Scene.unity", EditorGUIUtility.FindTexture("SceneAsset Icon"), null);
 }
 public static void CreateAsset(UnityEngine.Object asset, string pathName)
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(asset.GetInstanceID(), ScriptableObject.CreateInstance <DoCreateNewAsset>(), pathName, AssetPreview.GetMiniThumbnail(asset), null);
 }
        private static void CreateAudioMixer()
        {
            Texture2D icon = EditorGUIUtility.IconContent("AudioMixerController Icon").image as Texture2D;

            ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateAudioMixer>(), "NewAudioMixer.mixer", icon, null);
        }
        private static void CreateScriptAsset(string templatePath, string destName)
        {
            if (Path.GetFileName(templatePath).ToLower().Contains("test"))
            {
                string str1 = AssetDatabase.GetUniquePathNameAtSelectedPath(destName);
                if (!str1.ToLower().Contains("/editor/"))
                {
                    string str2 = str1.Substring(0, str1.Length - destName.Length - 1);
                    string str3 = Path.Combine(str2, "Editor");
                    if (!Directory.Exists(str3))
                    {
                        AssetDatabase.CreateFolder(str2, "Editor");
                    }
                    str1 = Path.Combine(str3, destName).Replace("\\", "/");
                }
                destName = str1;
            }
            string    extension = Path.GetExtension(destName);
            Texture2D image;

            if (extension != null)
            {
                // ISSUE: reference to a compiler-generated field
                if (ProjectWindowUtil.\u003C\u003Ef__switch\u0024map1F == null)
                {
                    // ISSUE: reference to a compiler-generated field
                    ProjectWindowUtil.\u003C\u003Ef__switch\u0024map1F = new Dictionary <string, int>(4)
                    {
                        {
                            ".js",
                            0
                        },
                        {
                            ".cs",
                            1
                        },
                        {
                            ".boo",
                            2
                        },
                        {
                            ".shader",
                            3
                        }
                    };
                }
                int num;
                // ISSUE: reference to a compiler-generated field
                if (ProjectWindowUtil.\u003C\u003Ef__switch\u0024map1F.TryGetValue(extension, out num))
                {
                    switch (num)
                    {
                    case 0:
                        image = EditorGUIUtility.IconContent("js Script Icon").image as Texture2D;
                        goto label_16;

                    case 1:
                        image = EditorGUIUtility.IconContent("cs Script Icon").image as Texture2D;
                        goto label_16;

                    case 2:
                        image = EditorGUIUtility.IconContent("boo Script Icon").image as Texture2D;
                        goto label_16;

                    case 3:
                        image = EditorGUIUtility.IconContent("Shader Icon").image as Texture2D;
                        goto label_16;
                    }
                }
            }
            image = EditorGUIUtility.IconContent("TextAsset Icon").image as Texture2D;
label_16:
            ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, (EndNameEditAction)ScriptableObject.CreateInstance <DoCreateScriptAsset>(), destName, image, templatePath);
        }
 private static void CreateAudioMixer()
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, (EndNameEditAction)ScriptableObject.CreateInstance <DoCreateAudioMixer>(), "NewAudioMixer.mixer", EditorGUIUtility.IconContent("AudioMixerController Icon").image as Texture2D, (string)null);
 }
        static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
        {
            GenericMenu gm = new GenericMenu();

            int selectedInstanceID = serializedProperty.objectReferenceValue != null?serializedProperty.objectReferenceValue.GetInstanceID() : 0;


            bool foundDefaultAsset = false;
            var  type    = UnityEditor.UnityType.FindTypeByName(typeName);
            int  classID = type != null ? type.persistentTypeID : 0;

            BuiltinResource[] resourceList = null;

            // Check the assets for one that matches the default name.
            if (classID > 0)
            {
                resourceList = EditorGUIUtility.GetBuiltinResourceList(classID);
                foreach (var resource in resourceList)
                {
                    if (resource.m_Name == defaultFieldName)
                    {
                        gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                        resourceList      = resourceList.Where(x => x != resource).ToArray();
                        foundDefaultAsset = true;
                        break;
                    }
                }
            }

            // If no defalut asset was found, add defualt null value.
            if (!foundDefaultAsset)
            {
                gm.AddItem(new GUIContent(defaultFieldName), selectedInstanceID == 0, AssetPopupMenuCallback, new object[] { 0, serializedProperty });
            }

            // Add items from asset database
            foreach (var property in AssetDatabase.FindAllAssets(new SearchFilter()
            {
                classNames = new[] { typeName }
            }))
            {
                gm.AddItem(new GUIContent(property.name), property.instanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { property.instanceID, serializedProperty });
            }

            // Add builtin items, except for the already added default item.
            if (classID > 0 && resourceList != null)
            {
                foreach (var resource in resourceList)
                {
                    gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                }
            }

            // Create item
            gm.AddSeparator("");
            gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
            {
                var newAsset = Activator.CreateInstance <T>();
                var doCreate = ScriptableObject.CreateInstance <DoCreateNewAsset>();
                doCreate.SetProperty(serializedProperty);
                ProjectWindowUtil.StartNameEditingIfProjectWindowExists(newAsset.GetInstanceID(), doCreate, "New " + typeName + "." + fileExtension, AssetPreview.GetMiniThumbnail(newAsset), null);
            });

            gm.DropDown(buttonRect);
        }