public static TrackGroup CreateUTestTrackGroup(Cutscene cutscene) { string trackGroupName = UTest_GROUP_NAME; GameObject actorGroupGO = new GameObject(trackGroupName, typeof(UTestTrackGroup)); actorGroupGO.transform.parent = cutscene.transform; UTestTrackGroup actorTrackGroup = actorGroupGO.GetComponent <UTestTrackGroup>(); actorTrackGroup.Actor = cutscene.transform.Find("NguiPanel/Mouse"); return(actorTrackGroup); }
protected override void updateHeaderControl5(Rect position) { Transform actor = (TrackGroup.Behaviour as UTestTrackGroup).Actor; Color temp = GUI.color; GUI.color = (actor == null) ? Color.red : Color.green; int controlID = GUIUtility.GetControlID("UTestTrackGroup".GetHashCode(), FocusType.Passive, position); GUI.enabled = !(state.IsInPreviewMode && (actor == null)); if (GUI.Button(position, string.Empty, styles.pickerStyle)) { if (actor == null) { EditorGUIUtility.ShowObjectPicker <Transform>(actor, true, string.Empty, controlID); } else { Selection.activeGameObject = actor.gameObject; } } GUI.enabled = true; if (Event.current.commandName == "ObjectSelectorUpdated") { if (EditorGUIUtility.GetObjectPickerControlID() == controlID) { GameObject pickedObject = EditorGUIUtility.GetObjectPickerObject() as GameObject; if (pickedObject != null) { UTestTrackGroup atg = (TrackGroup.Behaviour as UTestTrackGroup); Undo.RecordObject(atg, string.Format("Changed {0}", atg.name)); atg.Actor = pickedObject.transform; } } } GUI.color = temp; }
/// <summary> /// Draw the inspector /// </summary> public override void OnInspectorGUI() { base.serializedObject.Update(); UTestTrackGroup actorGroup = base.serializedObject.targetObject as UTestTrackGroup; TimelineTrack[] tracks = actorGroup.GetTracks(); Cutscene cutscene = actorGroup.Cutscene; bool isCutsceneActive = false; if (cutscene == null) { EditorGUILayout.HelpBox("Track Group must be a child of a Cutscene in the hierarchy", MessageType.Error); } else { isCutsceneActive = !(cutscene.State == Cutscene.CutsceneState.Inactive); if (isCutsceneActive) { EditorGUILayout.HelpBox("Cutscene is Active. Actors cannot be altered at the moment.", MessageType.Info); } } GUI.enabled = !isCutsceneActive; if (actorProperty.objectReferenceValue == null) { actorProperty.objectReferenceValue = actorGroup.Cutscene.transform.Find("NguiPanel/Mouse"); } EditorGUILayout.PropertyField(actorProperty, new GUIContent("actor")); GUI.enabled = true; EditorGUILayout.PropertyField(optimizable); if (tracks.Length > 0) { containerFoldout = EditorGUILayout.Foldout(containerFoldout, tracksContent); if (containerFoldout) { EditorGUI.indentLevel++; foreach (TimelineTrack track in tracks) { EditorGUILayout.BeginHorizontal(); track.name = EditorGUILayout.TextField(track.name); if (GUILayout.Button(inspectorIcon, GUILayout.Width(24))) { Selection.activeObject = track; } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } } if (GUILayout.Button(addTrackContent)) { CutsceneControlHelper.ShowAddTrackContextMenu(actorGroup); } base.serializedObject.ApplyModifiedProperties(); }