public override void OnInspectorGUI() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; // See if there's a bounding box yet BoundingBoxManipulate bbm = GameObject.FindObjectOfType <BoundingBoxManipulate>(); AppBar toolbar = GameObject.FindObjectOfType <AppBar>(); if (bbm == null || toolbar == null) { HUXEditorUtils.ErrorMessage( "Couldn't find a bounding box prefab and/or manipulation toolbar in the scene. Bounding box target won't work without them.", AddBoundingBox); } HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(bbt); }
public override void OnInspectorGUI() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(bbt); }
public override void OnInspectorGUI() { BoundingBoxTarget bbt = (BoundingBoxTarget)target; HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnSelected"); HUXEditorUtils.DrawFilterTagField(serializedObject, "TagOnDeselected"); /*EditorGUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("Bounds method", GUILayout.MaxWidth(100)); * bbt.BoundsCalculationMethod = (BoundingBox.BoundsCalculationMethodEnum)EditorGUILayout.EnumPopup(bbt.BoundsCalculationMethod, GUILayout.MaxWidth(155)); * switch (bbt.BoundsCalculationMethod) * { * case BoundingBox.BoundsCalculationMethodEnum.MeshFilterBounds: * HUXEditorUtils.DrawSubtleMiniLabel("Uses all MeshFilters to calculate bounds. This setting is more accurate (especially for flat objects), but will only calculate bounds for mesh-based objects."); * break; * * case BoundingBox.BoundsCalculationMethodEnum.RendererBounds: * HUXEditorUtils.DrawSubtleMiniLabel("Uses all Renderers to calculate bounds. This setting is less accurate, but can calculate bounds for objects like particle systems."); * break; * } * EditorGUILayout.EndHorizontal();*/ bbt.PermittedOperations = (BoundingBoxManipulate.OperationEnum)HUXEditorUtils.EnumCheckboxField <BoundingBoxManipulate.OperationEnum>( "Permitted Operations", bbt.PermittedOperations, "Default", BoundingBoxManipulate.OperationEnum.ScaleUniform | BoundingBoxManipulate.OperationEnum.RotateY | BoundingBoxManipulate.OperationEnum.Drag, BoundingBoxManipulate.OperationEnum.Drag); bbt.FlattenPreference = (BoundingBox.FlattenModeEnum)EditorGUILayout.EnumPopup("Flattening mode", bbt.FlattenPreference); bbt.ShowAppBar = EditorGUILayout.Toggle("Toolbar Display", bbt.ShowAppBar); HUXEditorUtils.SaveChanges(target, serializedObject); }
public override void OnInspectorGUI() { CompoundButton cb = (CompoundButton)target; // Don't perform this check at runtime if (!Application.isPlaying) { // First, check our colliders // Get the components we need for the button to be visible Rigidbody parentRigidBody = cb.GetComponent <Rigidbody>(); Collider parentCollider = cb.GetComponent <Collider>(); // Get all child colliders that AREN'T the parent collider HashSet <Collider> childColliders = new HashSet <Collider>(cb.GetComponentsInChildren <Collider>()); childColliders.Remove(parentCollider); bool foundError = false; EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (parentCollider == null) { if (childColliders.Count == 0) { foundError = true; GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("Error: Button must have at least 1 collider to be visible, preferably on the root transform.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { cb.gameObject.AddComponent <BoxCollider>(); } } else if (parentRigidBody == null) { foundError = true; GUI.color = HUXEditorUtils.ErrorColor; EditorGUILayout.LabelField("Error: Button requires a rigidbody if colliders are only present on child transforms.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { Rigidbody rb = cb.gameObject.AddComponent <Rigidbody>(); rb.isKinematic = true; } } else if (!parentRigidBody.isKinematic) { foundError = true; GUI.color = HUXEditorUtils.WarningColor; EditorGUILayout.LabelField("Warning: Button rigid body is not kinematic - this is not recommended.", EditorStyles.wordWrappedLabel); if (GUILayout.Button("Fix now")) { parentRigidBody.isKinematic = true; } } } // If our colliders were fine, next check the interaction manager to make sure the button will be visible if (!foundError) { FocusManager fm = GameObject.FindObjectOfType <FocusManager>(); if (fm != null) { if (fm.RaycastLayerMask != (fm.RaycastLayerMask | (1 << cb.gameObject.layer))) { foundError = true; GUI.color = HUXEditorUtils.WarningColor; EditorGUILayout.LabelField("Warning: Button is not on a layer that the focus manager can see. Button will not receive input until either the button's layer or the FocusManager's RaycastLayerMask is changed. (This may be intentional.)", EditorStyles.wordWrappedLabel); if (fm.RaycastLayerMask.value != 0) { if (GUILayout.Button("Fix now")) { // Put the button on the first layer that the layer mask can see for (int i = 0; i < 32; i++) { if (fm.RaycastLayerMask == (fm.RaycastLayerMask | (1 << i))) { cb.gameObject.layer = i; break; } } } } } } else { EditorGUILayout.LabelField("(Couldn't find a focus manager to perform visibility check)", EditorStyles.wordWrappedLabel); } } if (!foundError) { GUI.color = HUXEditorUtils.SuccessColor; EditorGUILayout.LabelField("Button is good to go!", EditorStyles.wordWrappedLabel); } EditorGUILayout.EndVertical(); } GUI.color = HUXEditorUtils.DefaultColor; HUXEditorUtils.BeginSectionBox("Button properties", HUXEditorUtils.DefaultColor); // Draw the filter tag field HUXEditorUtils.DrawFilterTagField(serializedObject, "FilterTag"); cb.RequireGaze = EditorGUILayout.Toggle("Require Gaze", cb.RequireGaze); cb.ButtonState = (Button.ButtonStateEnum)EditorGUILayout.EnumPopup("Button State", cb.ButtonState); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.BeginSectionBox("Commonly referenced components", HUXEditorUtils.DefaultColor); cb.MainCollider = HUXEditorUtils.DropDownComponentField <Collider>("Main collider", cb.MainCollider, cb.transform); cb.MainRenderer = HUXEditorUtils.DropDownComponentField <MeshRenderer>("Main renderer", cb.MainRenderer, cb.transform); HUXEditorUtils.EndSectionBox(); HUXEditorUtils.SaveChanges(cb); }