public override void OnInspectorGUI() { serializedObject.Update(); VRTK_InteractableObject targ = (VRTK_InteractableObject)target; GUILayout.Space(10); GUIStyle guiStyle = EditorStyles.foldout; FontStyle previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewTouch = EditorGUILayout.Foldout(viewTouch, "Touch Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewTouch) { EditorGUI.indentLevel++; targ.highlightOnTouch = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("highlightOnTouch"), targ.highlightOnTouch); if (targ.highlightOnTouch) { EditorGUILayout.PropertyField(serializedObject.FindProperty("touchHighlightColor")); } GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("rumbleOnTouch")); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float y = EditorGUILayout.FloatField(targ.rumbleOnTouch.y, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float x = EditorGUILayout.FloatField(targ.rumbleOnTouch.x, GUILayout.MinWidth(10f)); targ.rumbleOnTouch = new Vector2(x, y); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("allowedTouchControllers")); EditorGUILayout.PropertyField(serializedObject.FindProperty("hideControllerOnTouch")); EditorGUI.indentLevel--; } //Grab Layout GUILayout.Space(10); targ.isGrabbable = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("isGrabbable"), targ.isGrabbable); if (targ.isGrabbable != isGrabbableLastState && targ.isGrabbable) { viewGrab = true; } isGrabbableLastState = targ.isGrabbable; if (targ.isGrabbable) { guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewGrab = EditorGUILayout.Foldout(viewGrab, "Grab Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewGrab) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty("isDroppable")); EditorGUILayout.PropertyField(serializedObject.FindProperty("isSwappable")); EditorGUILayout.PropertyField(serializedObject.FindProperty("holdButtonToGrab")); EditorGUILayout.PropertyField(serializedObject.FindProperty("grabOverrideButton")); GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("rumbleOnGrab")); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float y = EditorGUILayout.FloatField(targ.rumbleOnGrab.y, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float x = EditorGUILayout.FloatField(targ.rumbleOnGrab.x, GUILayout.MinWidth(10f)); targ.rumbleOnGrab = new Vector2(x, y); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("allowedGrabControllers")); targ.precisionSnap = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("precisionSnap", "Precision Grab(Snap)"), targ.precisionSnap); if (!targ.precisionSnap) { EditorGUILayout.PropertyField(serializedObject.FindProperty("rightSnapHandle")); EditorGUILayout.PropertyField(serializedObject.FindProperty("leftSnapHandle")); } EditorGUILayout.PropertyField(serializedObject.FindProperty("hideControllerOnGrab")); EditorGUILayout.PropertyField(serializedObject.FindProperty("stayGrabbedOnTeleport")); targ.grabAttachMechanic = (VRTK_InteractableObject.GrabAttachType)EditorGUILayout.EnumPopup(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("grabAttachMechanic"), targ.grabAttachMechanic); if (Array.IndexOf(hasDetachThreshold, targ.grabAttachMechanic) >= 0) { EditorGUILayout.PropertyField(serializedObject.FindProperty("detachThreshold")); if (targ.grabAttachMechanic == VRTK_InteractableObject.GrabAttachType.Spring_Joint) { EditorGUILayout.PropertyField(serializedObject.FindProperty("springJointStrength")); EditorGUILayout.PropertyField(serializedObject.FindProperty("springJointDamper")); } } EditorGUILayout.PropertyField(serializedObject.FindProperty("throwMultiplier")); EditorGUILayout.PropertyField(serializedObject.FindProperty("onGrabCollisionDelay")); EditorGUI.indentLevel--; } } GUILayout.Space(10); targ.isUsable = EditorGUILayout.Toggle(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("isUsable"), targ.isUsable); if (targ.isUsable != isUsableLastState && targ.isUsable) { viewUse = true; } isUsableLastState = targ.isUsable; if (targ.isUsable) { guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewUse = EditorGUILayout.Foldout(viewUse, "Use Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewUse) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(serializedObject.FindProperty("useOnlyIfGrabbed")); EditorGUILayout.PropertyField(serializedObject.FindProperty("holdButtonToUse")); EditorGUILayout.PropertyField(serializedObject.FindProperty("useOverrideButton")); EditorGUILayout.PropertyField(serializedObject.FindProperty("pointerActivatesUseAction")); GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(VRTK_EditorUtilities.BuildGUIContent <VRTK_InteractableObject>("rumbleOnUse")); EditorGUI.indentLevel--; GUILayout.Label("Strength", GUILayout.MinWidth(49f)); float y = EditorGUILayout.FloatField(targ.rumbleOnUse.y, GUILayout.MinWidth(10f)); GUILayout.Label("Duration", GUILayout.MinWidth(50f)); float x = EditorGUILayout.FloatField(targ.rumbleOnUse.x, GUILayout.MinWidth(10f)); targ.rumbleOnUse = new Vector2(x, y); EditorGUI.indentLevel++; GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("allowedUseControllers")); EditorGUILayout.PropertyField(serializedObject.FindProperty("hideControllerOnUse")); EditorGUI.indentLevel--; } } if (targ.GetComponent <VRTK_InteractableObject>().GetType().IsSubclassOf(typeof(VRTK_InteractableObject))) { GUILayout.Space(10); guiStyle = EditorStyles.foldout; previousStyle = guiStyle.fontStyle; guiStyle.fontStyle = FontStyle.Bold; viewCustom = EditorGUILayout.Foldout(viewCustom, "Custom Options", guiStyle); guiStyle.fontStyle = previousStyle; GUILayout.Space(2); if (viewCustom) { List <string> excludedProperties = new List <string>(); foreach (var ioProperty in typeof(VRTK_InteractableObject).GetFields()) { excludedProperties.Add(ioProperty.Name); } DrawPropertiesExcluding(serializedObject, excludedProperties.ToArray()); } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.Update(); var adaptiveQuality = (VRTK_AdaptiveQuality)target; if (adaptiveQuality.GetComponent <SteamVR_Camera>() == null) { EditorGUILayout.HelpBox(NoSteamVR_CameraFoundHelpBoxText, MessageType.Error); return; } EditorGUILayout.HelpBox(DontDisableHelpBoxText, adaptiveQuality.enabled ? MessageType.Warning : MessageType.Error); EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("active")); EditorGUILayout.PropertyField(serializedObject.FindProperty("drawDebugVisualization")); EditorGUILayout.PropertyField(serializedObject.FindProperty("respondsToKeyboardShortcuts")); EditorGUILayout.PropertyField(serializedObject.FindProperty("respondsToCommandLineArguments")); EditorGUILayout.PropertyField(serializedObject.FindProperty("msaaLevel")); float minimumRenderScale = adaptiveQuality.minimumRenderScale; float maximumRenderScale = adaptiveQuality.maximumRenderScale; AddHeader(adaptiveQuality, "minimumRenderScale"); EditorGUILayout.BeginHorizontal(); { var fieldInfo = adaptiveQuality.GetType().GetField("minimumRenderScale"); var rangeAttribute = (RangeAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(RangeAttribute)); EditorGUI.BeginChangeCheck(); { float maxFloatWidth = GUI.skin.textField.CalcSize(new GUIContent(1.23f.ToString(CultureInfo.InvariantCulture))).x; minimumRenderScale = EditorGUILayout.FloatField(minimumRenderScale, GUILayout.MaxWidth(maxFloatWidth)); EditorGUILayout.MinMaxSlider( ref minimumRenderScale, ref maximumRenderScale, rangeAttribute.min, rangeAttribute.max); maximumRenderScale = EditorGUILayout.FloatField(maximumRenderScale, GUILayout.MaxWidth(maxFloatWidth)); } if (EditorGUI.EndChangeCheck()) { serializedObject.FindProperty("minimumRenderScale").floatValue = Mathf.Clamp((float)Math.Round(minimumRenderScale, 2), rangeAttribute.min, rangeAttribute.max); serializedObject.FindProperty("maximumRenderScale").floatValue = Mathf.Clamp((float)Math.Round(maximumRenderScale, 2), rangeAttribute.min, rangeAttribute.max); } } EditorGUILayout.EndHorizontal(); if (maximumRenderScale > adaptiveQuality.BiggestAllowedMaximumRenderScale()) { EditorGUILayout.HelpBox(MaximumRenderScaleTooBigHelpBoxText, MessageType.Error); } EditorGUILayout.PropertyField(serializedObject.FindProperty("maximumRenderTargetDimension")); EditorGUILayout.PropertyField(serializedObject.FindProperty("renderScaleFillRateStepSizeInPercent")); int maxRenderScaleLevel = Mathf.Max(adaptiveQuality.renderScales.Count - 1, 0); bool disabled = maxRenderScaleLevel == 0 || !Application.isPlaying; EditorGUI.BeginDisabledGroup(disabled); { AddHeader(adaptiveQuality, "overrideRenderScale"); if (disabled) { EditorGUI.EndDisabledGroup(); { EditorGUILayout.HelpBox(NoRenderScaleLevelsYetHelpBoxText, MessageType.Info); } EditorGUI.BeginDisabledGroup(true); } adaptiveQuality.overrideRenderScale = EditorGUILayout.Toggle( VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderScale"), adaptiveQuality.overrideRenderScale); EditorGUI.BeginDisabledGroup(!adaptiveQuality.overrideRenderScale); { adaptiveQuality.overrideRenderScaleLevel = EditorGUILayout.IntSlider( VRTK_EditorUtilities.BuildGUIContent <VRTK_AdaptiveQuality>("overrideRenderScaleLevel"), adaptiveQuality.overrideRenderScaleLevel, 0, maxRenderScaleLevel); } EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }