0
我創建了一個Unity編輯器類,我想在其中選擇我的「瓷磚」並添加「牆」。它適用於單個選擇,但我無法解決它的多個選擇。我發現用[CanEditMultipleObjects]編輯多個對象
[CanEditMultipleObjects]
但本身並不能幫助。這裏的編輯腳本:
#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(TileMorpherMonoBehaviour))]
[CanEditMultipleObjects]
public class TileMorpher : Editor {
public override void OnInspectorGUI() {
TileControl tileControl = (target as TileMorpherMonoBehaviour).gameObject.GetComponent<TileControl>();
if (GUILayout.Button("Add wall")) {
tileControl.addWall();
}
if (GUILayout.Button("Remove wall")) {
tileControl.removeWall();
}
}
}
#endif