Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Mivrel · Mar 16, 2017 at 09:12 AM · componentsrenamefoldersexplorer

Moving/renaming folder

Hello.

Is there a way to change/rename folder with scripts for example and make Unity to load it properly when these scripts are attached to a Game Objects?

When I rename folder or move scripts to another I get "The associated script can not be loaded. [...]".

I do this in Unity and outside with moving .meta files too.

Thank you.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image herDev · Mar 16, 2017 at 01:23 PM 0
Share

Hi, So you are just trying to rename a folder (which contains scripts) in your project window or in the system file browser? This should work fine, I recommend trying it with a new test project and seeing if you get the same results. Also, one question, are the game objects prefabs, that are dynamically loaded and not initially active in the scene?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Cliffinho · Mar 16, 2017 at 08:34 PM

Do operations with assets outside of Unity is not recomended, instead, using the class AssetDatabase, and ofcourse, you can do custom inspector/editor tools to improve the management of all kind assets (folders, animatior controllers, materials etc...). Look to AssetDatabase class, and see some classes to build editor tools: Editor Window, GUILayout, EditorGUILayout.

Look at this example script, he creates a window and list all folders of your project:

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEditor;
 using UnityEngine;
 
 public class FoldersListWindow : EditorWindow
 {
     private List<Folder> assetsFolders = new List<Folder>();
     private Vector2 foldersListScroll;
 
     [MenuItem("Window/FolderList %#o")]
     private static void Init()
     {
         FoldersListWindow window = GetWindow<FoldersListWindow>();
         window.titleContent = new GUIContent { text = "Folder List" };
         window.Show();
     }
 
     private void OnEnable()
     {
         foreach (string folder in AssetDatabase.GetSubFolders("Assets"))
         {
             assetsFolders.Add(new Folder(folder));
         }
     }
 
     private void OnGUI()
     {
         GUILayout.BeginArea(new Rect(1f, 1f, Screen.width / 3f, Screen.height), GUI.skin.box);
         foldersListScroll = EditorGUILayout.BeginScrollView(foldersListScroll, true, true);
 
         DrawFolders(assetsFolders);
 
         EditorGUILayout.EndScrollView();
         GUILayout.EndArea();
     }
 
     private void DrawFolders(List<Folder> foldersList)
     {
         for (int i = 0; i < foldersList.Count; i++)
         {
             EditorGUILayout.BeginVertical(GUILayout.Width(Screen.width / 3f));
 
             foldersList[i].isFoldoutShown = EditorGUILayout.Foldout(foldersList[i].isFoldoutShown, foldersList[i].folderName);
 
             if (foldersList[i].haveSubFolders && foldersList[i].isFoldoutShown)
             {
                 EditorGUI.indentLevel++;
 
                 DrawFolders(foldersList[i].subFolders);
 
                 EditorGUI.indentLevel--;
             }
 
             EditorGUILayout.EndVertical();
         }
     }
 }
 
 // THIS CLASS IS USED TO REPRESENT A FOLDER (WITH SUB FOLDERS) IN THE ASSETS FOLDER
 public class Folder
 {
     public string fullPath;
     public string folderName;
     public bool haveSubFolders;
     public bool isFoldoutShown;
     public int subFoldersCount;
     public List<Folder> subFolders;
 
     public Folder(string path)
     {
         fullPath = path;
         folderName = GetOnlyFolderName(fullPath);
         haveSubFolders = CheckForSubFolders(fullPath);
 
         if (haveSubFolders)
         {
             subFolders = new List<Folder>();
             string[] folders = AssetDatabase.GetSubFolders(fullPath);
 
             foreach (string item in folders)
             {
                 subFolders.Add(new Folder(item));
             }
 
             subFoldersCount = subFolders.Count;
             isFoldoutShown = true;        
         }
         else
         {
             haveSubFolders = false;
             subFoldersCount = 0;
             isFoldoutShown = false;
         }
     }
 
     private bool CheckForSubFolders(string path)
     {
         string[] folders = AssetDatabase.GetSubFolders(path);
         if (folders.Length > 0)
             return true;
         else
             return false;
     }
 
     private string GetOnlyFolderName(string path)
     {
         return path.Substring(path.LastIndexOf('/') + 1);
     }
 }

Really a bit "complicated", but it gives you the power of manipulate all assets in a project.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tulpan · Jun 03, 2017 at 11:31 AM

I suggest to try KrojamSoft BatchRename

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Change Name Take 001 Animation 3 Answers

How can i change icon file name for Android on Unity? 1 Answer

Renaming GameObject Issues in Unity 2019.4.12f1 1 Answer

List of reserved variables such as transform and rigidbody 1 Answer

are saved transforms quicker than .transform? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges