static void DrawLandmarkOutputDropdownButton(Component currentOutput, LandmarkController landmarkController) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PrefixLabel(k_OutputTypeLabel); var buttonLabel = ObjectNames.NicifyVariableName(currentOutput != null ? TrimLandmarkOutputName(currentOutput.GetType().Name) : k_OutputDropdownButtonDefaultLabel); if (EditorGUILayout.DropdownButton(new GUIContent(buttonLabel), FocusType.Keyboard)) { var menu = new GenericMenu(); var definition = landmarkController.landmarkDefinition; if (definition != null) { foreach (var outputType in definition.outputTypes) { var showChecked = currentOutput != null && currentOutput.GetType() == outputType; var outputTypeName = TrimLandmarkOutputName(outputType.Name); menu.AddItem(new GUIContent(outputTypeName), showChecked, () => { Undo.RegisterFullObjectHierarchyUndo(landmarkController.gameObject, k_ModifyUndoLabel); landmarkController.SetOutputType(outputType); }); } menu.ShowAsContext(); } } } }
static void DrawSettingsInfo(SerializedProperty settingsProperty, LandmarkController landmarkController) { var definition = landmarkController.landmarkDefinition; if (definition != null && definition.settingsType != null) { EditorGUILayout.PropertyField(settingsProperty); var landmarkSettings = settingsProperty.objectReferenceValue as Component; if (landmarkSettings != null && landmarkSettings.GetType() != definition.settingsType) { // Settings is the wrong type, try to get component on it to find the right type landmarkSettings = landmarkSettings.GetComponent(definition.settingsType); settingsProperty.objectReferenceValue = landmarkSettings; } if (landmarkSettings == null) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.HelpBox("Settings component is invalid.", MessageType.Error); if (GUILayout.Button(styles.addDefaultCompButtonContent, GUILayout.Height(k_AddDefaultComponentButtonHeight))) { settingsProperty.objectReferenceValue = Undo.AddComponent(landmarkController.gameObject, definition.settingsType); } } } } }
// Start is called before the first frame update private void Start() { _proxies = FindObjectsOfType <Proxy>(); _polygonLandmark = FindObjectOfType <LandmarkController>(); _boundingRec = _polygonLandmark.output as LandmarkOutputPolygon; if (_boundingRec != null) { _boundingRec.dataChanged += GetParentSize; } var toggles = FindObjectsOfType <Toggle>().ToList(); _lockPlayArea = toggles.Find(toggle => toggle.name == "LockPlayArea"); // Make playhead invisible //GetComponent<Renderer>().enabled = false; }
static void DrawSourceInfo(Component sourceComponent, LandmarkController landmarkController) { if (sourceComponent == null) { EditorGUILayout.HelpBox(k_NoSourceWarningLabel, MessageType.Warning); } else { var sourceAction = sourceComponent as IAction; if (sourceAction != null && sourceComponent.gameObject == landmarkController.gameObject) { var rwoInParent = sourceComponent.GetComponentInParent <Proxy>(); if (rwoInParent == null) { EditorGUILayout.HelpBox(k_SourceActionNoParentWarning, MessageType.Warning); } } } }
static void DrawOutputInfo(SerializedProperty outputProperty, LandmarkController landmarkController) { EditorGUILayout.PropertyField(outputProperty); var output = outputProperty.objectReferenceValue as Component; var validOutputType = false; var definition = landmarkController.landmarkDefinition; if (definition == null) { return; } if (output != null && definition.outputTypes != null) { var currentOutputType = output.GetType(); foreach (var validType in definition.outputTypes) { if (validType == currentOutputType) { validOutputType = true; } } } if (!validOutputType) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.HelpBox("Output component is invalid.", MessageType.Error); if (GUILayout.Button(styles.addDefaultCompButtonContent, GUILayout.Height(k_AddDefaultComponentButtonHeight))) { EditorApplication.delayCall += () => { Undo.RegisterFullObjectHierarchyUndo(landmarkController.gameObject, k_ModifyUndoLabel); landmarkController.SetOutputType(definition.outputTypes[0]); }; } } } }
static void DrawLandmarkDefinitionDropdownButton(ICalculateLandmarks landmarkSource, LandmarkController landmarkController) { var definition = landmarkController.landmarkDefinition; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PrefixLabel(k_DefinitionNameLabel); var buttonLabel = ObjectNames.NicifyVariableName(definition == null ? k_DefinitionDropdownButtonDefaultLabel : definition.name); if (EditorGUILayout.DropdownButton(new GUIContent(buttonLabel), FocusType.Keyboard)) { var menu = new GenericMenu(); const string baseTitle = ""; foreach (var availableDefinition in landmarkSource.AvailableLandmarkDefinitions) { var title = baseTitle + ObjectNames.NicifyVariableName(availableDefinition.name); var currentlySelected = definition != null && string.Equals(availableDefinition.name, definition.name); menu.AddItem(new GUIContent(title), currentlySelected, () => { Undo.RegisterFullObjectHierarchyUndo(landmarkController.gameObject, k_ModifyUndoLabel); landmarkController.source = landmarkSource; landmarkController.landmarkDefinition = availableDefinition; }); } menu.ShowAsContext(); } } }