Esempio n. 1
0
 void OnDestroy()
 {
     if (ivrCardboard == null && ivr != null)
     {
         cardboardHead = ivr.headTarget.GetComponent <IVR_CardboardHead>();
         if (cardboardHead != null)
         {
             DestroyImmediate(cardboardHead, true);
         }
     }
 }
Esempio n. 2
0
        void OnEnable()
        {
            ivrCardboard = (IVR_Cardboard)target;
            ivr          = ivrCardboard.GetComponent <InstantVR>();

            if (ivr != null)
            {
                cardboardHead = ivr.headTarget.GetComponent <IVR_CardboardHead>();
                if (cardboardHead == null)
                {
                    cardboardHead           = ivr.headTarget.gameObject.AddComponent <IVR_CardboardHead>();
                    cardboardHead.extension = ivrCardboard;
                }

                IVR_Extension[] extensions = ivr.GetComponents <IVR_Extension>();
                if (ivrCardboard.priority == -1)
                {
                    ivrCardboard.priority = extensions.Length - 1;
                }
                for (int i = 0; i < extensions.Length; i++)
                {
                    if (ivrCardboard == extensions[i])
                    {
                        while (i < ivrCardboard.priority)
                        {
                            MoveUp(cardboardHead);
                            ivrCardboard.priority--;
                            //Debug.Log ("Cardboard Move up to : " + i + " now: " + ivrRift.priority);
                        }
                        while (i > ivrCardboard.priority)
                        {
                            MoveDown(cardboardHead);
                            ivrCardboard.priority++;
                            //Debug.Log ("Cardboard Move down to : " + i + " now: " + ivrRift.priority);
                        }
                    }
                }
            }
        }