public void LoadDefaultSet() { _interactionSets = GetComponentsInChildren <InteractionSetComponent>(); if (_interactionSets.Length == 0) { return; } // If the default interaction set is null, set it to something sensible if (defaultInteractionSet == null && _interactionSets != null) { int highestWeight = 0; foreach (InteractionSetComponent comp in _interactionSets) { if (comp.Weight >= highestWeight) { highestWeight = comp.Weight; defaultInteractionSet = comp; } } } if (defaultInteractionSet != null) { SetInteractionSet(defaultInteractionSet); } }
public void SetInteractionSet(InteractionSetComponent activeSet) { if (activeSet != null) { foreach (Renderer renderer in GetComponentsInChildren <Renderer>()) { renderer.enabled = renderer.gameObject.activeSelf; } } // Destroy the rest (or disable it if we're in debug mode so that we can switch in between interaction sets // in the debugging panel) foreach (InteractionSetComponent comp in GetComponentsInChildren <InteractionSetComponent>()) { if (comp != activeSet) { #if DEBUG comp.gameObject.SetActive(false); #else GameObject.Destroy(comp.gameObject); #endif } } #if DEBUG _current = activeSet; #endif }
public void OnDebugPanelGUI() { GUILayout.BeginVertical(); GUILayout.Label("Current Interaction Set: " + _current.gameObject.name); foreach (InteractionSetComponent comp in _interactionSets) { if (GUILayout.Button(comp.gameObject.name)) { _current.gameObject.SetActive(false); _current = comp; _current.gameObject.SetActive(true); } } GUILayout.EndVertical(); }