I recently wrote some small tools, record and share them
tool
[MenuItem("Assets/工具/赋值")]
public static void SetSelectedPrefabsValue()
{
Debug.Log($"数量{
Selection.gameObjects.Length}");
if (Selection.gameObjects.Length == 0)return;
foreach (var obj in Selection.gameObjects)
{
GameObject go = obj;
/*
ScriptA a= go.GetComponent<ScriptA>();
ScriptB b= go.GetComponentInChildren<ScriptB>();
a.fireOutLine = effect;
*/
PrefabUtility.SavePrefabAsset(go);
}
}
Nanny tutorial:
Write the operation you want to perform in the comment area. For example, here is to find b from the sub-object and assign it to the fireOutLine attribute of a.
It is used when there are a large number of prefabs with the same script that need to be mounted on nodes, or when a large number of prefabs of the same type need to perform the same operation.
Instructions for use: Select all Prefabs that need to be modified, right-click Tools/Assignment Execute
Inspector mounting attribute, and Find attribute in Start
Mounting properties improves code readability and maintainability, and is often faster than using Find.
How to display Private properties in Inspector
[SerializeField] private int a;//显示私有
[HideInInspector] public int b;//隐藏公有