protected virtual void Awake() { xrUIColors = GetComponent <XRUI_Colors>(); LookForXRFeedback(); xrFeedback.isEnabled = isEnabled; if (!isEnabled) { return; } }
public void CreateXRUIColors() { LookForXRUIColor(); if (xrUIColors == null) { xrUIColors = gameObject.AddComponent <XRUI_Colors>(); } else { Debug.Log("You already have a XRUIColors on your game object or a child of it"); } }
private void LookForXRUIColor() { if (xrUIColors != null) { return; } xrUIColors = GetComponentInChildren <XRUI_Colors>(); //try to find a XRUIColors on object or any child element if (xrUIColors == null) { throw new System.Exception("XR Feedback Color needs a XRUIColor reference to work properly."); } }
//TODO: Se não tiver xrFeedback setado, dar um warning de que tu precisa ter um xrFeedback //TODO: Criar naughty attributes button pra criar automatico um xrfeedback protected virtual void OnValidate() { xrUIColors = GetComponent <XRUI_Colors>(); LookForXRFeedback(); xrFeedback.isEnabled = isEnabled; //Check if the uicolor is used with a Feedback Color script. If it's, refresh the normal color on target XRUI_FeedbackColor feedbackColor = GetComponentInChildren <XRUI_FeedbackColor>(); if (feedbackColor != null) { feedbackColor.RefreshElementColor(); } }
private void ConfigureFeedback(ref GameObject go, bool isScale) { //Set object active to false to don't call the Awake methods of components go.SetActive(false); XRUI_Colors xrUIColors = go.AddComponent <XRUI_Colors>(); XRUI_Feedback xrUIFeedback = go.AddComponent <XRUI_Feedback>(); XRUI_FeedbackColor xRUIFeedbackColor = go.AddComponent <XRUI_FeedbackColor>(); xRUIFeedbackColor.xrUIColors = xrUIColors; if (isScale) { xrUIColors.normalColor = scaleElementColor; } else { xrUIColors.normalColor = rotationElementColor; } xrUIFeedback.nearColliderType = XRUI_Feedback.NearColliderType.Sphere; xrUIFeedback.nearColliderRadius = 0.3f; if (feedbackType.Equals("Mesh")) { xRUIFeedbackColor.feedbackType = XRUI_FeedbackColor.VisualFeedbackType.MeshRenderer; } else { xRUIFeedbackColor.feedbackType = XRUI_FeedbackColor.VisualFeedbackType.Outline; } //after configure all components re-active gameObject so all the awake calls gona occurs go.SetActive(true); xRUIFeedbackColor.RefreshElementColor(); }