private void CheckExcludeButton(RoomAuthoring otherRoomAuthoring) { var previousColor = GUI.backgroundColor; GUI.backgroundColor = Color.red; if (GUILayout.Button("x", GUILayout.MaxWidth(20))) { var networkAuthoring = authoring.GetComponentInParent <RoomNetworkAuthoring>(); var parent = networkAuthoring.transform; var gameObject = new GameObject("New Exclude Portal", typeof(RoomExcludePortalAuthoring)); Undo.RegisterCreatedObjectUndo(gameObject, "Create Exclude Portal"); gameObject.transform.SetParent(parent, false); var exclude = gameObject.GetComponent <RoomExcludePortalAuthoring>(); var excludeSerializedObject = new SerializedObject(exclude); excludeSerializedObject.FindProperty("roomAuthoringA").objectReferenceValue = authoring; excludeSerializedObject.FindProperty("roomAuthoringB").objectReferenceValue = otherRoomAuthoring; excludeSerializedObject.ApplyModifiedProperties(); GameObjectEditorIconHelper.SetIcon(gameObject, GameObjectEditorIconHelper.LabelIcon.Red); gameObject.name = exclude.GetPortalName(); } GUI.backgroundColor = previousColor; }
void OnEnable() { authoring = (RoomAuthoring)target; var gameObject = authoring.gameObject; if (!GameObjectEditorIconHelper.GetHasIcon(gameObject)) { GameObjectEditorIconHelper.SetIcon(gameObject, GameObjectEditorIconHelper.LabelIcon.Green); } }
void OnEnable() { authoring = (RoomExcludePortalAuthoring)target; var gameObject = authoring.gameObject; if (!GameObjectEditorIconHelper.GetHasIcon(gameObject)) { GameObjectEditorIconHelper.SetIcon(gameObject, GameObjectEditorIconHelper.LabelIcon.Red); } }