protected override void OnChildInspectorGUI() { base.OnChildInspectorGUI(); // COPY SETTINGS EditorGUILayout.BeginVertical(boxStyle); GUILayout.Space(4); // SPACE settingsReference = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Copy From", "Assign the GameObject from which you want to extract the settings."), settingsReference, typeof(GameObject), true); if (settingsReference != null) { GUILayout.Space(4); // SPACE HUDNavigationElement element = settingsReference.GetComponent <HUDNavigationElement> (); if (element != null) { // show paste button if (GUILayout.Button("Copy Settings", GUILayout.Height(18))) { hudTarget.CopySettings(element); } } else { // show error message EditorGUILayout.HelpBox("No HUDNavigationElement component found on GameObject.", MessageType.Error); } } GUILayout.Space(4); // SPACE EditorGUILayout.EndVertical(); GUILayout.Space(8); // SPACE }
void OnEnable() { editorTitle = "HUD Navigation Element"; splashTexture = (Texture2D)Resources.Load("splashTexture_Element", typeof(Texture2D)); hudTarget = (HUDNavigationElement)target; }
protected override void OnEnable() { base.OnEnable(); editorTitle = "HUD Navigation Element"; splashTexture = (Texture2D)Resources.Load("Textures/splashTexture_Element", typeof(Texture2D)); hudTarget = (HUDNavigationElement)target; }
void CreateRandomElement() { // create demo gameobject at random position GameObject go = new GameObject("Random Element"); go.transform.SetParent(ElementHolder.transform); go.transform.position = new Vector3(Random.Range(-25f, 25f), Random.Range(.5f, 25f), Random.Range(-25f, 25f)); // add navigation element HUDNavigationElement element = go.AddComponent <HUDNavigationElement> (); //######################## // Element Customizations //######################## // use settings asset / manual settings if (Settings != null) { element.Settings = Settings; } else { // set random icon if (Icons.Length > 0) { element.Icon = Icons [Random.Range(0, Icons.Length)]; } // icon sizes element.RadarIcon.IconSize = 8; element.CompassBarIcon.IconSize = 22; element.IndicatorIcon.IconSize = 16; element.OffscreenIndicatorIcon.IconSize = 16; // icon colors Color _color = new Color(Random.value, Random.value, Random.value, 1f); element.RadarIcon.IconColor = _color; element.CompassBarIcon.IconColor = _color; element.IndicatorIcon.IconColor = _color; element.OffscreenIndicatorIcon.IconColor = _color; // indicator settings element.ShowIndicator = true; element.IgnoreIndicatorRadius = true; //... } }
public void ChangeIndicatorColors(HUDNavigationElement element) { // EXAMPLE: // => Change the indicator colors of the element if (element.Indicator != null) { // onscreen icon color if (element.Indicator.OnscreenIcon != null) { element.Indicator.OnscreenIcon.color = Color.magenta; } // offscreen icon color if (element.Indicator.OffscreenIcon != null) { element.Indicator.OffscreenIcon.color = Color.magenta; } } }
void HandleItemPickUp() { // check for pickup items if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains("PickUp")) { // get HUD navigation element component HUDNavigationElement element = hit.collider.gameObject.GetComponent <HUDNavigationElement> (); if (element != null) { // show pickup text if (element.Indicator != null) { pickupText = element.Indicator.GetCustomTransform("pickupText"); if (pickupText != null) { pickupText.gameObject.SetActive(true); } } // wait for interaction input and destroy gameobject if (Input.GetKeyDown(KeyCode.E)) { Destroy(element.gameObject); } } } else { // reset pickup text if (pickupText != null) { pickupText.gameObject.SetActive(false); pickupText = null; } } }
private void Awake() { _collider = GetComponent <Collider>(); _rigidBody = GetComponent <Rigidbody>(); _hudNavigationElement = GetComponent <HUDNavigationElement>(); }
void HandlePrismColorChange() { // check for colored prisms if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, interactionDistance, layerMask) && hit.collider.name.Contains("Prism")) { // get HUD navigation element component HUDNavigationElement element = hit.collider.gameObject.GetComponentInChildren <HUDNavigationElement> (); if (element != null) { // show interaction text if (element.Indicator != null) { interactionText = element.Indicator.GetCustomTransform("interactionText"); if (interactionText != null) { interactionText.gameObject.SetActive(true); } } // wait for interaction input and change prism color if (Input.GetKeyDown(KeyCode.E)) { // generate random color Color randomColor = Random.ColorHSV(0f, 1f, 1f, 1f, .5f, 1f); // change radar color if (element.Radar != null) { element.Radar.ChangeIconColor(randomColor); } // change compass bar color if (element.CompassBar != null) { element.CompassBar.ChangeIconColor(randomColor); } // change indicator colors if (element.Indicator != null) { element.Indicator.ChangeIconColor(randomColor); element.Indicator.ChangeOffscreenIconColor(randomColor); } // change minimap color if (element.Minimap != null) { element.Minimap.ChangeIconColor(randomColor); } // change prism material color Renderer renderer = element.transform.parent.GetComponent <Renderer> (); if (renderer != null) { renderer.material.color = new Color(randomColor.r, randomColor.g, randomColor.b, renderer.material.color.a); } } } } else { // reset interaction text if (interactionText != null) { interactionText.gameObject.SetActive(false); interactionText = null; } } }
public void OnElementLeaveRadius(HUDNavigationElement element, NavigationElementType type) { Debug.LogFormat("{0} element of {1} left radius.", type, element.name); }
public void OnElementEnterRadius(HUDNavigationElement element, NavigationElementType type) { Debug.LogFormat("{0} element of {1} entered radius.", type, element.name); }
public void OnElementDisappeared(HUDNavigationElement element, NavigationElementType type) { Debug.LogFormat("{0} element of {1} disappeared.", type, element.name); }
void Update() { // update interaction input HUDNavigationElement element = null; bool raycast = Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, interactionDistance, layerMask); if (raycast) { // get HUD navigation element component element = hit.collider.gameObject.GetComponentInChildren <HUDNavigationElement> (); // check for interaction input if (Input.GetKeyDown(KeyCode.E)) { if (element != null) { ExampleRotatePrism prismRotator = hit.collider.gameObject.GetComponent <ExampleRotatePrism> (); if (element.Icon != interactedIcon) { // change icon element.Icon = interactedIcon; // stop prism rotation if (prismRotator != null) { prismRotator.enabled = false; } } else { // reset icon element.Icon = defaultIcon; // start prism rotation if (prismRotator != null) { prismRotator.enabled = true; } } // refresh element element.Refresh(); } } } // animate interaction point if (interactionPoint != null) { interactionPoint.rectTransform.sizeDelta = Vector2.Lerp(interactionPoint.rectTransform.sizeDelta, Vector2.one * ((raycast && element != null) ? 20f : 5f), Time.deltaTime * 8f); } // show/hide interaction text if (interactionText != null) { interactionText.enabled = raycast && element != null; } // update radar zoom / indicator border input if (Input.GetKey(KeyCode.C) && HUDNavigationSystem.Instance.RadarZoom < 5f) { HUDNavigationSystem.Instance.RadarZoom += .0175f; } if (Input.GetKey(KeyCode.V) && HUDNavigationSystem.Instance.RadarZoom > .1f) { HUDNavigationSystem.Instance.RadarZoom -= .0175f; } if (Input.GetKey(KeyCode.B) && HUDNavigationSystem.Instance.IndicatorOffscreenBorder < .9f) { HUDNavigationSystem.Instance.IndicatorOffscreenBorder += .01f; } if (Input.GetKey(KeyCode.N) && HUDNavigationSystem.Instance.IndicatorOffscreenBorder > .035f) { HUDNavigationSystem.Instance.IndicatorOffscreenBorder -= .01f; } }