public bool BeginNewAssetCreation(int instanceID, EndNameEditAction newAssetEndAction, string filePath, Texture2D icon, string newAssetResourceFile)
 {
     string uniquePathNameAtSelectedPath;
     if (!filePath.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase))
     {
         uniquePathNameAtSelectedPath = AssetDatabase.GetUniquePathNameAtSelectedPath(filePath);
     }
     else
     {
         uniquePathNameAtSelectedPath = AssetDatabase.GenerateUniqueAssetPath(filePath);
     }
     if (!IsPathDataValid(uniquePathNameAtSelectedPath))
     {
         object[] args = new object[] { uniquePathNameAtSelectedPath, filePath };
         Debug.LogErrorFormat("Invalid generated unique path '{0}' (input path '{1}')", args);
         this.Clear();
         return false;
     }
     this.m_InstanceID = instanceID;
     this.m_Path = uniquePathNameAtSelectedPath;
     this.m_Icon = icon;
     this.m_EndAction = newAssetEndAction;
     this.m_ResourceFile = newAssetResourceFile;
     Selection.activeObject = EditorUtility.InstanceIDToObject(instanceID);
     return true;
 }
		public void Clear()
		{
			this.m_EndAction = null;
			this.m_InstanceID = 0;
			this.m_Path = string.Empty;
			this.m_Icon = null;
			this.m_ResourceFile = string.Empty;
		}
 internal static void EndNameEditAction(EndNameEditAction action, int instanceId, string pathName, string resourceFile)
 {
   pathName = AssetDatabase.GenerateUniqueAssetPath(pathName);
   if (!((UnityEngine.Object) action != (UnityEngine.Object) null))
     return;
   action.Action(instanceId, pathName, resourceFile);
   action.CleanUp();
 }
 public void Clear()
 {
   this.m_EndAction = (EndNameEditAction) null;
   this.m_InstanceID = 0;
   this.m_Path = string.Empty;
   this.m_Icon = (Texture2D) null;
   this.m_ResourceFile = string.Empty;
 }
 public void Clear()
 {
     this.m_EndAction = null;
     this.m_InstanceID = 0;
     this.m_Path = "";
     this.m_Icon = null;
     this.m_ResourceFile = "";
 }
		internal static void EndNameEditAction(EndNameEditAction action, int instanceId, string pathName, string resourceFile)
		{
			pathName = AssetDatabase.GenerateUniqueAssetPath(pathName);
			if (action != null)
			{
				action.Action(instanceId, pathName, resourceFile);
				action.CleanUp();
			}
		}
Beispiel #7
0
 internal static void EndNameEditAction(UnityEditor.ProjectWindowCallback.EndNameEditAction action, int instanceId, string pathName, string resourceFile)
 {
     pathName = AssetDatabase.GenerateUniqueAssetPath(pathName);
     if (action != null)
     {
         action.Action(instanceId, pathName, resourceFile);
         action.CleanUp();
     }
 }
		public virtual void BeginCreateNewAsset(int instanceID, EndNameEditAction endAction, string pathName, Texture2D icon, string resourceFile)
		{
			this.ClearRenameAndNewNodeState();
			this.GetCreateAssetUtility().BeginNewAssetCreation(instanceID, endAction, pathName, icon, resourceFile);
			this.SyncFakeItem();
			if (!base.GetRenameOverlay().BeginRename(this.GetCreateAssetUtility().originalName, instanceID, 0f))
			{
				Debug.LogError("Rename not started (when creating new asset)");
			}
		}
		public void BeginNewAssetCreation(int instanceID, EndNameEditAction newAssetEndAction, string pathName, Texture2D icon, string newAssetResourceFile)
		{
			if (!pathName.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase))
			{
				pathName = AssetDatabase.GetUniquePathNameAtSelectedPath(pathName);
			}
			else
			{
				pathName = AssetDatabase.GenerateUniqueAssetPath(pathName);
			}
			this.m_InstanceID = instanceID;
			this.m_Path = pathName;
			this.m_Icon = icon;
			this.m_EndAction = newAssetEndAction;
			this.m_ResourceFile = newAssetResourceFile;
			Selection.activeObject = EditorUtility.InstanceIDToObject(instanceID);
		}
Beispiel #10
0
        public static void StartNameEditingIfProjectWindowExists(int instanceID, UnityEditor.ProjectWindowCallback.EndNameEditAction endAction, string pathName, Texture2D icon, string resourceFile)
        {
            ProjectBrowser projectBrowserIfExists = GetProjectBrowserIfExists();

            if (projectBrowserIfExists != null)
            {
                projectBrowserIfExists.Focus();
                projectBrowserIfExists.BeginPreimportedNameEditing(instanceID, endAction, pathName, icon, resourceFile);
                projectBrowserIfExists.Repaint();
            }
            else
            {
                if (!pathName.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase))
                {
                    pathName = "Assets/" + pathName;
                }
                EndNameEditAction(endAction, instanceID, pathName, resourceFile);
                Selection.activeObject = EditorUtility.InstanceIDToObject(instanceID);
            }
        }
 internal void BeginPreimportedNameEditing(int instanceID, EndNameEditAction endAction, string pathName, Texture2D icon, string resourceFile)
 {
   if (!this.Initialized())
     this.Init();
   this.EndRenaming();
   bool isCreatingNewFolder = endAction is DoCreateFolder;
   if (this.m_ViewMode == ProjectBrowser.ViewMode.TwoColumns)
   {
     if (this.m_SearchFilter.GetState() != SearchFilter.State.FolderBrowsing)
       this.SelectAssetsFolder();
     pathName = this.ValidateCreateNewAssetPath(pathName);
     if (!this.m_ListAreaState.m_CreateAssetUtility.BeginNewAssetCreation(instanceID, endAction, pathName, icon, resourceFile))
       return;
     this.ShowFolderContents(AssetDatabase.GetMainAssetInstanceID(this.m_ListAreaState.m_CreateAssetUtility.folder), true);
     this.m_ListArea.BeginNamingNewAsset(this.m_ListAreaState.m_CreateAssetUtility.originalName, instanceID, isCreatingNewFolder);
   }
   else
   {
     if (this.m_ViewMode != ProjectBrowser.ViewMode.OneColumn)
       return;
     if (this.m_SearchFilter.IsSearching())
       this.ClearSearch();
     AssetsTreeViewGUI gui = this.m_AssetTree.gui as AssetsTreeViewGUI;
     if (gui != null)
       gui.BeginCreateNewAsset(instanceID, endAction, pathName, icon, resourceFile);
     else
       Debug.LogError((object) "Not valid defaultTreeViewGUI!");
   }
 }
 public static void StartNameEditingIfProjectWindowExists(int instanceID, EndNameEditAction endAction, string pathName, Texture2D icon, string resourceFile)
 {
   ProjectBrowser projectBrowserIfExists = ProjectWindowUtil.GetProjectBrowserIfExists();
   if ((bool) ((UnityEngine.Object) projectBrowserIfExists))
   {
     projectBrowserIfExists.Focus();
     projectBrowserIfExists.BeginPreimportedNameEditing(instanceID, endAction, pathName, icon, resourceFile);
     projectBrowserIfExists.Repaint();
   }
   else
   {
     if (!pathName.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase))
       pathName = "Assets/" + pathName;
     ProjectWindowUtil.EndNameEditAction(endAction, instanceID, pathName, resourceFile);
     Selection.activeObject = EditorUtility.InstanceIDToObject(instanceID);
   }
 }