I found that many artists love to ask why the program unity3d is always lost in materials? I do not rule out that material will be lost when U3D has a bug? However, this is often caused by human operations.
1. If it is not saved, it will be uploaded.
This operation is terrible. Remember !! No matter what you do in U3D, you must first save the scenario when uploading SVN. Remember Ctrl + S !! If you do not save the file, you may lose the material.
2. My computer is fine. Why do you lose materials wherever you are?
I found a very interesting phenomenon. Every time I went to the front of the art computer to view its SVN project, I would find a variety of "yellow exclamation marks" and serious conflicts in the entire project. Then the conversation between the program and art is: "Is this resource useful? No deletion is used. I will update it again ..." Hahaha I think only programmers may be very sensitive to conflicts, but I don't think it's a blame for Art. Art is a very abstract thing, the program cannot be executed without a semicolon.
3. manage texture maps
If the materials and textures are not properly managed by the project, you will find that many identical images have different names but are still in use .. This may be due to the fact that several pieces of fine arts are being done at the same time, which may result in a waste of resources.
4. material loss due to special effects
Let me give you a practical example. We have two projects and special effects. In the past, we encountered the problem of material loss due to special effects in scenarios. The reason is that the person who made the special effect has modified the special effect, but the person who made the special effect does not know it, because the special effect may be used in many scenarios.
As shown in, if the prefab under the preiject is dragged into the hierarchy view, the two are associated, if you modify prefab directly in the project view, the prefab associated with it in all hierarchy views will be modified. There is no problem with small changes. If some major changes occur, the prefab in hierarchy view may be lost or broken. However, if you reference the same prefab in many scenarios, it will be hard to find so many scenarios.
<Ignore_js_op>
Selecting a prefab In The hierarch view is positive, and then clicking select in the Inspector view on the right will automatically find the prefab object in the project view. In the reverse direction, how does one find the prefab referenced in hierarchy view from the project view?
As shown in, unity3d provides a function. In the project view, right-click a prefab And choose find references in scene, at this time, unity will automatically help you find the prefab gameobject in the hierarchy view in the current scenario.
<Ignore_js_op>
However, this method has some limitations, that is, it can only find the current scenario. If your prefab has been referenced in many scenarios, you cannot find it, I decided to write a small tool for art, hey. [Applescript] How can I view the copy code in plain text?
01020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546 |
[MenuItem ( "Assets/Check Prefab Use ?" ) ] private static void OnSearchForReferences ( ) { / / Make sure that you right-click a prefab if ( Selection.gameObjects.Length ! = 1 ) { return ; } / / Traverse all game scenarios foreach ( EditorBuildSettingsScene scene in EditorBuildSettings.scenes ) { if ( scene. enabled ) { / / Open scenario EditorApplication.OpenScene ( scene. path ) ; / / Obtain all game objects in a scenario GameObject []gos = ( GameObject[] ) FindObjectsOfType ( typeof ( GameObject ) ) ; foreach ( GameObject go in gos ) { / / Determine whether a gameobject is a prefab reference if ( PrefabUtility.GetPrefabType ( go ) = = PrefabType.PrefabInstance ) { UnityEngine.Object parentObject = EditorUtility.GetPrefabParent ( go ) ; string path = AssetDatabase.GetAssetPath ( parentObject ) ; / / Determine whether the prefab of the gameobject is in the same path as the prefab selected by right-click. if ( path = = AssetDatabase.GetAssetPath ( Selection.activeGameObject ) ) { / / Output scenario name and prefab Reference Path Debug.Log ( scene. path + " " + GetGameObjectPath ( go ) ) ; } } } } } } public static string GetGameObjectPath ( GameObject obj ) { string path = "/" + obj. name ; while ( obj.transform.parent ! = null ) { obj = obj.transform.parent.gameObject; path = "/" + obj. name + path ; } return path ; } |
As shown in, I can find the scenario that references this prefab. Here, I do not use the names of gameobject and Prefab. I think it is best not to use the names, because the names in hierarchy view can be modified at will, if it is changed, it cannot be found, and there are so many scenarios with unique names.
Is it easy? Hey. Another way is to dynamically load the prefab at runtime. However, in some scenarios, special effects have no meaning, but they are only displayed, and the program does not need to operate on them. With this small tool, when the art is changed to prefab, run the tool to check whether it is normally displayed in some scenarios? Hey, hey.
Forward and reverse lookup of prefab And gameobject