private void DrawProximitySelector() { DestroyImmediate(pcObject.GetComponent <Selector>()); ProximitySelector proximitySelector = pcObject.GetComponent <ProximitySelector>() ?? pcObject.AddComponent <ProximitySelector>(); EditorWindowTools.StartIndentedSection(); EditorGUILayout.HelpBox("The player can target usable objects (e.g., conversations on NPCs) when inside their trigger areas. Click Select Player Inspect to customize the Proximity Selector.", MessageType.None); proximitySelector.useKey = (KeyCode)EditorGUILayout.EnumPopup("'Use' Key", proximitySelector.useKey); proximitySelector.useButton = EditorGUILayout.TextField("'Use' Button", proximitySelector.useButton); EditorWindowTools.EndIndentedSection(); }
private void DisconnectDelegates() { selector = GetComponent <Selector>(); if (selector != null) { selector.useDefaultGUI = true; selector.SelectedUsableObject -= OnSelectedUsable; selector.DeselectedUsableObject -= OnDeselectedUsable; } proximitySelector = GetComponent <ProximitySelector>(); if (proximitySelector != null) { proximitySelector.useDefaultGUI = true; proximitySelector.SelectedUsableObject -= OnSelectedUsable; proximitySelector.DeselectedUsableObject -= OnDeselectedUsable; } HideControls(); }
private void ConnectDelegates() { DisconnectDelegates(); // Make sure we're not connecting twice. selector = GetComponent <Selector>(); if (selector != null) { selector.useDefaultGUI = false; selector.SelectedUsableObject += OnSelectedUsable; selector.DeselectedUsableObject += OnDeselectedUsable; defaultUseMessage = selector.defaultUseMessage; } proximitySelector = GetComponent <ProximitySelector>(); if (proximitySelector != null) { proximitySelector.useDefaultGUI = false; proximitySelector.SelectedUsableObject += OnSelectedUsable; proximitySelector.DeselectedUsableObject += OnDeselectedUsable; if (string.IsNullOrEmpty(defaultUseMessage)) { defaultUseMessage = proximitySelector.defaultUseMessage; } } }
private void Awake() { proximitySelector = GetComponent<ProximitySelector>(); }
private void Awake() { proximitySelector = GetComponent <ProximitySelector>(); playerMovement = GetComponent <PlayerMovement>(); }