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 NSTHitGroupsSettings hgSettings = NSTHitGroupsSettings.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; NSTHitGroupsSettings hgSettings = NSTHitGroupsSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME); 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.Space(); NSTHitGroupsSettingsEditor.DrawLinkToSettings(); EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
public override void OnNstPostAwake() { base.OnNstPostAwake(); // Collect all interface callbacks iMonitorHealth = new List <IMonitorVitals>(); nst.GetComponentsInChildren(true, iMonitorHealth); //<IMonitorHealth>(true); int hitGroupCount = NSTHitGroupsSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME).hitGroupTags.Count; // Make sure the size of the hitgroup list is correct, could be more elegant but will do for now. while (hitGroupModifers.Count > hitGroupCount) { hitGroupModifers.RemoveAt(hitGroupModifers.Count - 1); } while (hitGroupModifers.Count < hitGroupCount) { hitGroupModifers.Add(1); } }