public override void OnGUI(Rect r, SerializedProperty _property, GUIContent _label) { EditorGUI.BeginProperty(r, GUIContent.none, _property); SerializedProperty hitGroupTagId = _property.FindPropertyRelative("hitGroupTagId"); SerializedProperty hitGroupTag = _property.FindPropertyRelative("hitGroupTag"); float line = r.yMin + 2; // Make sure settings exists so we can pull from the layers HitGroupSettings hgSettings = HitGroupSettings.Single; //.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME); GUIContent[] listitems = new GUIContent[hgSettings.hitGroupTags.Count]; // Populate list from current rewind layers in NSTRewindSettings for (int i = 0; i < listitems.Length; i++) { listitems[i] = new GUIContent(hgSettings.hitGroupTags[i]); // If the selected tag has moved to a new ID (tags have been added/removed/renamed) this will refind it, // otherwise it keeps the ID and will use whatever tag is at that index if (hitGroupTag.stringValue == hgSettings.hitGroupTags[i]) { hitGroupTagId.intValue = i; } } hitGroupTagId.intValue = EditorGUI.Popup(new Rect(r.xMin, line, r.width, 16), new GUIContent("Hit Group Tag"), hitGroupTagId.intValue, listitems); hitGroupTag.stringValue = (listitems.Length > hitGroupTagId.intValue) ? listitems[hitGroupTagId.intValue].text : "Untagged"; EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); EditorGUILayout.Space(); var _t = (NSTSampleHealth)target; HitGroupSettings hgSettings = HitGroupSettings.Single; //EditorGUILayout.PropertyField(serializedObject.FindProperty("authorityModel")); var vitals = serializedObject.FindProperty("vitals"); for (int i = 0; i < vitals.arraySize; i++) { EditorGUILayout.PropertyField(vitals.GetArrayElementAtIndex(i)); } int count = hgSettings.hitGroupTags.Count; // Resize the array if it is invalid while (_t.hitGroupModifers.Count > count) { _t.hitGroupModifers.RemoveAt(_t.hitGroupModifers.Count - 1); } while (_t.hitGroupModifers.Count < count) { _t.hitGroupModifers.Add(1f); } EditorGUILayout.LabelField("Hit Box Group Modifiers", (GUIStyle)"BoldLabel"); EditorGUILayout.BeginVertical("HelpBox"); Rect r = EditorGUILayout.GetControlRect(); EditorGUI.LabelField(r, "Hit Box Group", (GUIStyle)"BoldLabel"); r.xMin += EditorGUIUtility.labelWidth; EditorGUI.LabelField(r, "Dmg Multiplier", (GUIStyle)"BoldLabel"); for (int i = 0; i < count; i++) { _t.hitGroupModifers[i] = EditorGUILayout.FloatField(hgSettings.hitGroupTags[i], _t.hitGroupModifers[i]); } EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); HitGroupSettings.Single.DrawGui(target, true, false, true); }