Created
February 23, 2020 11:51
-
-
Save inertiave/91847d6a6958f87581ac3624f9e92b97 to your computer and use it in GitHub Desktop.
스크립트로 네스티드 프리팹을 편집하는 방법
How to edit nested prefab by script after 2018.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class EditPrefab { | |
[MenuItem("Prefab/Edit Prefabs")] | |
private static void EditPrefabs() { | |
AssetDatabase.StartAssetEditing(); | |
var prefabs = AssetDatabase.FindAssets("prefab t:Prefab", new string[] {"Assets/Prefabs"}); | |
foreach (var prefab in prefabs){ | |
var path = AssetDatabase.GUIDToAssetPath(prefab); | |
var loaded = PrefabUtility.LoadPrefabContents(path); | |
// change prefab here | |
UnityEngine.Object.DestroyImmediate(loaded.GetComponent(typeof(Collider))); | |
// unload | |
PrefabUtility.SaveAsPrefabAsset(loaded, path); | |
PrefabUtility.UnloadPrefabContents(loaded); | |
} | |
AssetDatabase.StopAssetEditing(); | |
AssetDatabase.SaveAssets(); | |
Debug.Log($"{prefabs.Length} items processed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment