protected virtual void Awake()
    {
        xrFeedback = GetComponent <XRUI_Feedback>();

        if (!xrFeedback.isEnabled)
        {
            return;
        }

        if (runOnNear)
        {
            xrFeedback.onNearEnter.AddListener(OnNearEnterFeedbackFunction);
            xrFeedback.onNearExit.AddListener(OnNearExitFeedbackFunction);
        }

        if (runOnTouch)
        {
            xrFeedback.onTouchEnter.AddListener(OnTouchEnterFeedbackFunction);
            xrFeedback.onTouchExit.AddListener(OnTouchExitFeedbackFunction);
        }

        if (runOnSelect)
        {
            xrFeedback.onSelectEnter.AddListener(OnSelectEnterFeedbackFunction);
            xrFeedback.onSelectExit.AddListener(OnSelectExitFeedbackFunction);
        }
    }
示例#2
0
 public void CreateXRUIFeedback()
 {
     if (xrFeedback == null)
     {
         xrFeedback = gameObject.AddComponent <XRUI_Feedback>();
     }
     else
     {
         Debug.Log("You already have a XRFeedback on your game object or a child of it");
     }
 }
示例#3
0
    private void LookForXRFeedback()
    {
        if (xrFeedback != null)
        {
            return;
        }

        xrFeedback = GetComponentInChildren <XRUI_Feedback>(); //try to find a xrFeedback on object or any child element
        if (xrFeedback == null)
        {
            throw new System.Exception("XRUIBase needs a XRFeedback reference to work properly.");
        }
    }
示例#4
0
    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();
    }