Exemple #1
0
        private void CreateImplementation()
        {
            DestroyImplementation();

            var avatar = VRAvatar.Active;

            if (avatar == null)
            {
                return;
            }

            var limb = avatar.GetLimb(m_Limb);

            if (limb == null)
            {
                return;
            }

            mImpl = limb.InstantiateControllerVisual();
            if (mImpl == null)
            {
                return;
            }

            mImpl.transform.SetParentAndIdentity(transform);
        }
Exemple #2
0
 private void DestroyImplementation()
 {
     if (mImpl != null)
     {
         Destroy(mImpl.gameObject);
         mImpl = null;
     }
 }
Exemple #3
0
        private void OnDestroy()
        {
            VRAvatar.AvatarChanged -= OnVRAvatarChanged;
            if (mImpl != null)
            {
#if UNITY_EDITOR
                if (!ReferenceEquals(mImpl, mPreviewProxy))
                {
                    // Implementation is the proxy
                    Destroy(mImpl.gameObject);
                }
#else
                Destroy(mImpl.gameObject);
#endif
                mImpl = null;
            }
        }
Exemple #4
0
        private void UpdatePreviewState()
        {
            // No previews while running...
            if (Application.isPlaying)
            {
                return;
            }

            if (m_ShowPreview)
            {
                mPreviewProxy           = gameObject.GetOrAddComponent <Devices.Emulator.Avatar.Controllers.EmulatorControllerVisualProxy>();
                mPreviewProxy.hideFlags = HideFlags.NotEditable | HideFlags.HideInInspector;
                mImpl = mPreviewProxy;
            }
            else
            {
                // NOTE: Preview proxy and implmentation are the same, we only want to delete the *component*
                DestroyImmediate(mPreviewProxy);
                mPreviewProxy = null;
                mImpl         = null;
            }
        }