//This is the function that makes the custom editor work public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); // Update the array property's representation in the inspector list.DoLayoutList(); // Have the ReorderableList do its work GUILayout.BeginHorizontal(); var defaultColor = GUI.color; var defaultBackgroundColor = GUI.backgroundColor; var editable = ((EnRaycastManager)target).m_Editable; GUI.backgroundColor = editable ? Color.gray : Color.green; if (GUILayout.Button(editable ? "Disable Editing" : "Editing")) { ((EnRaycastManager)target).m_Editable = !editable; } GUI.color = defaultColor; GUI.backgroundColor = defaultBackgroundColor; if (GUILayout.Button("Copy")) { string json = JsonUtility.ToJson(serializedObject.targetObject); GUIUtility.systemCopyBuffer = json; } if (GUILayout.Button("Paste")) { string json = GUIUtility.systemCopyBuffer; var gameObject = new GameObject("Temp"); EnRaycastManager jsonEnRaycastManager = gameObject.AddComponent <EnRaycastManager>(); JsonUtility.FromJsonOverwrite(json, jsonEnRaycastManager); if (jsonEnRaycastManager != null) { var manager = ((EnRaycastManager)target); manager.items = jsonEnRaycastManager.items.ToArray(); manager.m_ID = jsonEnRaycastManager.m_ID + 1; manager.m_Priority = jsonEnRaycastManager.m_Priority; manager.m_LayerMask = jsonEnRaycastManager.m_LayerMask; manager.m_RaycastMethodType = jsonEnRaycastManager.m_RaycastMethodType; manager.m_QueryTriggerInteraction = jsonEnRaycastManager.m_QueryTriggerInteraction; manager.m_RaycastAllwaysAllItems = jsonEnRaycastManager.m_RaycastAllwaysAllItems; manager.m_ExpectedCollisionColor = jsonEnRaycastManager.m_ExpectedCollisionColor; manager.m_NotExpectedCollisionColor = jsonEnRaycastManager.m_NotExpectedCollisionColor; manager.m_ExpectedNoCollisionColor = jsonEnRaycastManager.m_ExpectedNoCollisionColor; manager.m_HideDefaultHandle = jsonEnRaycastManager.m_HideDefaultHandle; manager.m_ShowRaycastTool = jsonEnRaycastManager.m_ShowRaycastTool; manager.m_DrawType = jsonEnRaycastManager.m_DrawType; manager.m_DrawWireView = jsonEnRaycastManager.m_DrawWireView; manager.m_DrawNormals = jsonEnRaycastManager.m_DrawNormals; manager.m_DrawText = jsonEnRaycastManager.m_DrawText; manager.m_DrawPointSize = jsonEnRaycastManager.m_DrawPointSize; EditorUtility.SetDirty(manager); } GameObject.DestroyImmediate(gameObject); } GUILayout.EndHorizontal(); // We need to call this so that changes on the Inspector are saved by Unity. serializedObject.ApplyModifiedProperties(); }
void Duplicate() { if (list.index != -1) { EnRaycastManager manager = (EnRaycastManager)serializedObject.targetObject; SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(list.index); list.serializedProperty.arraySize++; // then get that element var newIndex = list.serializedProperty.arraySize - 1; var newElement = list.serializedProperty.GetArrayElementAtIndex(newIndex); var typeProp = newElement.FindPropertyRelative("m_Type"); typeProp.enumValueIndex = element.FindPropertyRelative("m_Type").enumValueIndex; var expect = newElement.FindPropertyRelative("m_Expect"); expect.enumValueIndex = element.FindPropertyRelative("m_Expect").enumValueIndex; var color = newElement.FindPropertyRelative("m_Color"); color.colorValue = element.FindPropertyRelative("m_Color").colorValue; var origin = newElement.FindPropertyRelative("m_Origin"); origin.vector3Value = element.FindPropertyRelative("m_Origin").vector3Value; var direction = newElement.FindPropertyRelative("m_Direction"); direction.vector3Value = element.FindPropertyRelative("m_Direction").vector3Value; var maxDistance = newElement.FindPropertyRelative("m_MaxDistance"); maxDistance.floatValue = element.FindPropertyRelative("m_MaxDistance").floatValue; var radius = newElement.FindPropertyRelative("m_Radius"); radius.floatValue = element.FindPropertyRelative("m_Radius").floatValue; var height = newElement.FindPropertyRelative("m_Height"); height.floatValue = element.FindPropertyRelative("m_Height").floatValue; var size = newElement.FindPropertyRelative("m_Size"); size.vector3Value = element.FindPropertyRelative("m_Size").vector3Value; var heightAxis = newElement.FindPropertyRelative("m_HeightAxis"); heightAxis.enumValueIndex = element.FindPropertyRelative("m_HeightAxis").enumValueIndex; } }
/// <summary> /// Validates the object to ensure it is valid for the current ability. /// </summary> /// <param name="obj">The object being validated.</param> /// <returns>True if the object is valid. The object may not be valid if it doesn't have an ability-specific component attached.</returns> protected virtual bool ValidateObject(EnRaycastManager manager, GameObject obj) { if (obj == null || !obj.activeInHierarchy) { return(false); } // If an object id is specified then the object must have the Object Identifier component attached with the specified ID. if (manager.m_ObjectID != -1) { //var objectIdentifiers = obj.GetCachedParentComponents<Objects.ObjectIdentifier>(); //if (objectIdentifiers == null) { // return false; //} //var hasID = false; //for (int i = 0; i < objectIdentifiers.Length; ++i) { // if (objectIdentifiers[i].ID == manager.m_ObjectID) { // hasID = true; // break; // } //} //if (!hasID) { // return false; //} } return(true); }
public bool FilterRaycastHit(EnRaycastManager manager, EnRaycast enRaycast, RaycastHit hit, ref RaycastHit raycastHit) { #if FIRST_PERSON_CONTROLLER || THIRD_PERSON_CONTROLLER if (ValidateObject(manager, hit.collider.gameObject)) { raycastHit = hit; return(true); } #endif return(false); }
public bool FilterRaycastHitsAllNonAlloc(EnRaycastManager manager, EnRaycast enRaycast, int length, RaycastHit[] hits, ref RaycastHit raycastHit) { #if FIRST_PERSON_CONTROLLER || THIRD_PERSON_CONTROLLER for (int i = 0; i < length; i++) { var hitObject = hits[i].collider.gameObject; if (ValidateObject(manager, hitObject)) { raycastHit = hits[i]; return(true); } } #endif return(false); }
void onSelect(ReorderableList itemList) { // We when select an item, init the properties list for that item: if (0 <= itemList.index && itemList.index < itemList.count) { SerializedProperty element = itemList.serializedProperty.GetArrayElementAtIndex(itemList.index); Repaint(); } if (serializedObject != null && serializedObject.targetObject != null) { EnRaycastManager manager = (EnRaycastManager)serializedObject.targetObject; if (manager.m_Editable && manager.m_HideDefaultHandle) { Tools.current = Tool.None; } } }
public EnRaycastEventData(EnRaycastManager manager, EnRaycast cast) { Manager = manager; EnRaycast = cast; }
public bool FilterRaycastHitsAllNonAlloc(EnRaycastManager manager, EnRaycast enRaycast, int hitCount, RaycastHit[] hits, ref RaycastHit raycastHit) { raycastHit = GetClosestRaycastHit(enRaycast.m_Origin, hitCount, hits); return(true); }
public bool FilterRaycastHit(EnRaycastManager manager, EnRaycast enRaycast, RaycastHit hit, ref RaycastHit raycastHit) { raycastHit = hit; return(true); }
void DrawWindowInspector(int windowID) { GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); //GUIStyle textFieldStyle = new GUIStyle(GUI.skin.textField); buttonStyle.margin = new RectOffset(0, 5, 2, 0); EnRaycastManager manager = (EnRaycastManager)target; if (!manager.m_ShowRaycastTool) { return; } var defaultColor = GUI.color; var defaultBackgroundColor = GUI.backgroundColor; var editable = manager.m_Editable; GUI.backgroundColor = editable ? Color.gray : Color.green + Color.green * 0.2f; if (GUILayout.Button(editable ? "Disable Editing" : "Editing", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { manager.m_Editable = !editable; } GUI.color = defaultColor; GUI.backgroundColor = defaultBackgroundColor; if (GUILayout.Button("Test Raycast", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { RaycastHit raycastHit = new RaycastHit(); var item = manager.items[list.index]; if (item.RaycastMethod(manager, manager.m_LayerMask)) { if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit1) { manager.m_Collider1 = item.m_RaycastHit1.collider; } if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit2) { manager.m_Collider2 = item.m_RaycastHit2.collider; } if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit3) { manager.m_Collider3 = item.m_RaycastHit3.collider; } } manager.items[list.index] = item; } if (GUILayout.Button("Test Raycasts", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { bool success = true; for (int i = 0; i < manager.items.Length; i++) { var item = manager.items[i]; if (item.RaycastMethod(manager, manager.m_LayerMask)) { if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit1) { manager.m_RaycastHit1 = item.m_RaycastHit1; manager.m_Collider1 = item.m_RaycastHit1.collider; } if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit2) { manager.m_RaycastHit2 = item.m_RaycastHit2; manager.m_Collider2 = item.m_RaycastHit2.collider; } if (item.Success && item.m_Expect == EnRaycast.Expect.CollisionOverrideRaycastHit3) { manager.m_RaycastHit3 = item.m_RaycastHit3; manager.m_Collider3 = item.m_RaycastHit3.collider; } } if (!item.Success && success) { success = false; } manager.items[i] = item; if (!success && !manager.m_RaycastAllwaysAllItems) { manager.m_Success = false; break; } } manager.m_Success = success; } if (list.index != -1) { SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(list.index); var origin = element.FindPropertyRelative("m_Origin"); var radius = element.FindPropertyRelative("m_Radius"); var direction = element.FindPropertyRelative("m_Direction"); var maxDistance = element.FindPropertyRelative("m_MaxDistance"); if (GUILayout.Button("Round Values .0", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { origin.vector3Value = new Vector3( Mathf.Round(origin.vector3Value.x * 10) / 10, Mathf.Round(origin.vector3Value.y * 10) / 10, Mathf.Round(origin.vector3Value.z * 10) / 10 ); direction.vector3Value = new Vector3( Mathf.Round(direction.vector3Value.x * 10) / 10, Mathf.Round(direction.vector3Value.y * 10) / 10, Mathf.Round(direction.vector3Value.z * 10) / 10 ); maxDistance.floatValue = Mathf.Round(maxDistance.floatValue * 10) / 10; radius.floatValue = Mathf.Round(radius.floatValue * 10) / 10; } if (GUILayout.Button("Round Values .00", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { origin.vector3Value = new Vector3( Mathf.Round(origin.vector3Value.x * 100) / 100, Mathf.Round(origin.vector3Value.y * 100) / 100, Mathf.Round(origin.vector3Value.z * 100) / 100 ); direction.vector3Value = new Vector3( Mathf.Round(direction.vector3Value.x * 100) / 100, Mathf.Round(direction.vector3Value.y * 100) / 100, Mathf.Round(direction.vector3Value.z * 100) / 100 ); maxDistance.floatValue = Mathf.Round(maxDistance.floatValue * 100) / 100; radius.floatValue = Mathf.Round(radius.floatValue * 100) / 100; } } if (GUILayout.Button("Clear", buttonStyle, GUILayout.Width(200), GUILayout.Height(20))) { for (int i = 0; i < manager.items.Length; i++) { var item = manager.items[i]; item.Clear(); manager.items[i] = item; } } }
public void OnSceneGUI() { if (list.index != -1 && target != null) { EnRaycastManager manager = (EnRaycastManager)target; SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(list.index); if (manager.m_Editable) { //EnRaycast enRaycast = element. var typeProp = element.FindPropertyRelative("m_Type"); var raycastTypeValue = (EnRaycast.RaycastType)typeProp.enumValueIndex; var origin = element.FindPropertyRelative("m_Origin"); var direction = element.FindPropertyRelative("m_Direction"); var maxDistance = element.FindPropertyRelative("m_MaxDistance"); var radius = element.FindPropertyRelative("m_Radius"); var height = element.FindPropertyRelative("m_Height"); var size = element.FindPropertyRelative("m_Size"); var heightAxis = element.FindPropertyRelative("m_HeightAxis"); var heightAxisValue = (CapsuleBoundsHandle.HeightAxis)heightAxis.enumValueIndex; GUIStyle style = new GUIStyle(); style.normal.textColor = Color.black; var worldOrigin = EnDebugExtension.RotatePoint(manager.transform, manager.transform.position + origin.vector3Value); var worldDirection = EnDebugExtension.RotateDirection(manager.transform, direction.vector3Value); var position1 = worldOrigin; //go.transform.position + origin.vector3Value; var position2 = worldOrigin + worldDirection * maxDistance .floatValue; //go.transform.position + origin.vector3Value + (go.transform.rotation * direction.vector3Value) * maxDistance.floatValue; Vector3 destination = Vector3.zero; Vector3 heading = Vector3.zero; //Origin Handles.Label(position1, manager.m_DrawText ? "Origin " + origin.vector3Value : "", style); origin.vector3Value = EnDebugExtension.RotatePointInverse(manager.transform, Handles.PositionHandle(position1, Quaternion.identity)) - manager.transform.position; //Destination Handles.Label(position2, manager.m_DrawText ? "Destination " + position2 : "", style); destination = EnDebugExtension.RotatePointInverse(manager.transform, Handles.PositionHandle(position2, Quaternion.identity)) - manager.transform.position; heading = destination - origin.vector3Value; maxDistance.floatValue = heading.magnitude; direction.vector3Value = heading / maxDistance.floatValue; //This is now the normalized direction. switch (raycastTypeValue) { case EnRaycast.RaycastType.Raycast: case EnRaycast.RaycastType.RaycastAll: case EnRaycast.RaycastType.RaycastNonAlloc: break; case EnRaycast.RaycastType.CapsuleCast: case EnRaycast.RaycastType.CapsuleCastAll: case EnRaycast.RaycastType.CapsuleCastNonAlloc: m_CapsuleBoundsHandle.center = worldOrigin; m_CapsuleBoundsHandle.radius = radius.floatValue; m_CapsuleBoundsHandle.height = height.floatValue; m_CapsuleBoundsHandle.heightAxis = (CapsuleBoundsHandle.HeightAxis)heightAxis.enumValueIndex; EditorGUI.BeginChangeCheck(); m_CapsuleBoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { //Undo.RecordObject(element, "Change Bounds"); origin.vector3Value = EnDebugExtension.RotatePointInverse(manager.transform, m_CapsuleBoundsHandle.center) - manager.transform.position; radius.floatValue = m_CapsuleBoundsHandle.radius; height.floatValue = m_CapsuleBoundsHandle.height; } break; case EnRaycast.RaycastType.SphereCast: case EnRaycast.RaycastType.SphereCastAll: case EnRaycast.RaycastType.SphereCastNonAlloc: m_SphereBoundsHandle.center = worldOrigin; m_SphereBoundsHandle.radius = radius.floatValue; EditorGUI.BeginChangeCheck(); m_SphereBoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { //Undo.RecordObject(element, "Change Bounds"); origin.vector3Value = EnDebugExtension.RotatePointInverse(manager.transform, m_SphereBoundsHandle.center) - manager.transform.position; radius.floatValue = m_SphereBoundsHandle.radius; } break; case EnRaycast.RaycastType.BoxCast: case EnRaycast.RaycastType.BoxCastAll: case EnRaycast.RaycastType.BoxCastNonAlloc: // copy the target object's data to the handle m_BoxBoundsHandle.center = worldOrigin; m_BoxBoundsHandle.size = size.vector3Value; // draw the handle EditorGUI.BeginChangeCheck(); m_BoxBoundsHandle.DrawHandle(); if (EditorGUI.EndChangeCheck()) { // record the target object before setting new values so changes can be undone/redone //Undo.RecordObject((Object)element, "Change Bounds"); // copy the handle's updated data back to the target object origin.vector3Value = EnDebugExtension.RotatePointInverse(manager.transform, m_BoxBoundsHandle.center) - manager.transform.position; size.vector3Value = m_BoxBoundsHandle.size; //boundsExample.bounds = newBounds; } break; default: break; } serializedObject.ApplyModifiedProperties(); } if (target != null) { Handles.BeginGUI(); Rect windowRect = new Rect(Screen.width - 215, Screen.height - 180, 200, EditorGUIUtility.singleLineHeight * 2f); GUILayout.Window(667, windowRect, DrawWindowInspector, "Raycast Tool"); Handles.EndGUI(); } } }
// Draws the elements on the list void DrawListItems(Rect rect, int index, bool isActive, bool isFocused) { var defaultFontSize = GUI.skin.button.fontSize; GUI.skin.button.fontSize = 9; GUI.skin.button.alignment = TextAnchor.MiddleCenter; SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index); //The element in the list float spacing = EditorGUIUtility.singleLineHeight / 2; var currentViewWidth = EditorGUIUtility.currentViewWidth - 60; // Create a property field and label field for each property. var typeProp = element.FindPropertyRelative("m_Type"); var raycastTypeValue = (EnRaycast.RaycastType)typeProp.enumValueIndex; // The 'm_Type' property. Since the enum is self-evident, I am not making a label field for it. // The property field for m_Type (width 100, height of a single line) EditorGUI.PropertyField( new Rect(rect.x, rect.y + spacing, currentViewWidth * 0.4f, EditorGUIUtility.singleLineHeight), typeProp, GUIContent.none ); var expectProp = element.FindPropertyRelative("m_Expect"); var expectPropValue = (EnRaycast.Expect)typeProp.enumValueIndex; EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.4f, rect.y + spacing, currentViewWidth * 0.6f - 50, EditorGUIUtility.singleLineHeight), expectProp, GUIContent.none ); var executed = element.FindPropertyRelative("Executed").boolValue; var result = element.FindPropertyRelative("Result").boolValue; var status = element.FindPropertyRelative("Success").boolValue; EditorGUI.DrawRect(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 2 - spacing / 2, currentViewWidth, 2), result ? status ? expectedCollisionColor : notExpectedCollisionColor : expectedNoCollisionColor); var controlCount = RaycastTypeControlLength(raycastTypeValue) - 1; var heightStatusLine = EditorGUIUtility.singleLineHeight * controlCount + spacing * 3 - 2; EditorGUI.DrawRect(new Rect(rect.x - 11, rect.y + EditorGUIUtility.singleLineHeight * 2 - spacing * 2, 2, heightStatusLine), executed ? status ? expectedCollisionColor : expectedNoCollisionColor : Color.gray); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth - 50, rect.y + spacing, 50, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Color"), GUIContent.none ); EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 2, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Origin Offset"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 2, currentViewWidth * 0.60f - 88, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Origin"), GUIContent.none ); //copy if (GUI.Button(new Rect(rect.x + currentViewWidth - 88, rect.y + EditorGUIUtility.singleLineHeight * 2, 44, 18), "copy", GUI.skin.button)) { EnRaycastManager manager = (EnRaycastManager)serializedObject.targetObject; string json = JsonUtility.ToJson(manager.items[index]); GUIUtility.systemCopyBuffer = json; } //paste if (GUI.Button(new Rect(rect.x + currentViewWidth - 44, rect.y + EditorGUIUtility.singleLineHeight * 2, 44, 18), "paste", GUI.skin.button)) { string json = GUIUtility.systemCopyBuffer; EnRaycast enRaycast = JsonUtility.FromJson <EnRaycast>(json);//FromJsonOverwrite(json, enRaycast); element.FindPropertyRelative("m_Type").enumValueIndex = (int)enRaycast.m_Type; element.FindPropertyRelative("m_Expect").enumValueIndex = (int)enRaycast.m_Expect; element.FindPropertyRelative("m_Color").colorValue = enRaycast.m_Color; element.FindPropertyRelative("m_Origin").vector3Value = enRaycast.m_Origin; element.FindPropertyRelative("m_Direction").vector3Value = enRaycast.m_Direction; element.FindPropertyRelative("m_MaxDistance").floatValue = enRaycast.m_MaxDistance; element.FindPropertyRelative("m_Radius").floatValue = enRaycast.m_Radius; element.FindPropertyRelative("m_Height").floatValue = enRaycast.m_Height; element.FindPropertyRelative("m_HeightAxis").enumValueIndex = (int)enRaycast.m_HeightAxis; element.FindPropertyRelative("m_Size").vector3Value = enRaycast.m_Size; } EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 3, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Direction"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 3, currentViewWidth * 0.60f - 88, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Direction"), GUIContent.none ); //x if (GUI.Button(new Rect(rect.x + currentViewWidth - 88, rect.y + EditorGUIUtility.singleLineHeight * 3, 22, 18), "↔", GUI.skin.button)) { element.FindPropertyRelative("m_Direction").vector3Value = element.FindPropertyRelative("m_Direction").vector3Value != Vector3.right ? Vector3.right : Vector3.left; } //y if (GUI.Button(new Rect(rect.x + currentViewWidth - 66, rect.y + EditorGUIUtility.singleLineHeight * 3, 22, 18), "↕", GUI.skin.button)) { element.FindPropertyRelative("m_Direction").vector3Value = element.FindPropertyRelative("m_Direction").vector3Value != Vector3.up ? Vector3.up : Vector3.down; } //z if (GUI.Button(new Rect(rect.x + currentViewWidth - 44, rect.y + EditorGUIUtility.singleLineHeight * 3, 22, 18), element.FindPropertyRelative("m_Direction").vector3Value != Vector3.forward ? "→" : "←", GUI.skin.button)) { element.FindPropertyRelative("m_Direction").vector3Value = element.FindPropertyRelative("m_Direction").vector3Value != Vector3.forward ? Vector3.forward : Vector3.back; } //± if (GUI.Button(new Rect(rect.x + currentViewWidth - 22, rect.y + EditorGUIUtility.singleLineHeight * 3, 22, 18), "‼", GUI.skin.button)) { element.FindPropertyRelative("m_Direction").vector3Value *= -1; } EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 4, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Max Distance"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 4, currentViewWidth * 0.60f - 88, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_MaxDistance"), GUIContent.none ); //duplicate if (GUI.Button(new Rect(rect.x + currentViewWidth - 88, rect.y + EditorGUIUtility.singleLineHeight * 4, 88, 18), "duplicate", GUI.skin.button)) { Duplicate(); } switch (raycastTypeValue) { case EnRaycast.RaycastType.Raycast: case EnRaycast.RaycastType.RaycastAll: case EnRaycast.RaycastType.RaycastNonAlloc: break; case EnRaycast.RaycastType.SphereCast: case EnRaycast.RaycastType.SphereCastAll: case EnRaycast.RaycastType.SphereCastNonAlloc: EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Radius"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.60f, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Radius"), GUIContent.none ); break; case EnRaycast.RaycastType.CapsuleCast: case EnRaycast.RaycastType.CapsuleCastAll: case EnRaycast.RaycastType.CapsuleCastNonAlloc: EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Radius"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.60f, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Radius"), GUIContent.none ); EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 6, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Height"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 6, currentViewWidth * 0.60f, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Height"), GUIContent.none ); EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 7, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Axis Direction"); var heightAxis = element.FindPropertyRelative("m_HeightAxis"); var heightAxisValue = (CapsuleBoundsHandle.HeightAxis)heightAxis.enumValueIndex; EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 7, currentViewWidth * 0.6f, EditorGUIUtility.singleLineHeight), heightAxis, GUIContent.none ); break; case EnRaycast.RaycastType.BoxCast: case EnRaycast.RaycastType.BoxCastAll: case EnRaycast.RaycastType.BoxCastNonAlloc: EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.40f, EditorGUIUtility.singleLineHeight), "Size"); EditorGUI.PropertyField( new Rect(rect.x + currentViewWidth * 0.40f, rect.y + EditorGUIUtility.singleLineHeight * 5, currentViewWidth * 0.60f, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("m_Size"), GUIContent.none ); break; } GUI.skin.button.fontSize = defaultFontSize; }