コード例 #1
0
        private void OnEnable()
        {
#if UNITY_EDITOR
            ConsoleCallbackHandler.AddCallback(() => {
                Dependencies.RescanDictionary();
                StartCoroutine(ConsoleTheConsole());
            }, LogType.Error, "Can't remove");
            if (PrefabUtility.GetPrefabParent(gameObject) == null &&
                PrefabUtility.GetPrefabObject(gameObject) != null)
            {
                return;
            }
#endif
            // if (!gameObject.activeInHierarchy)
            //   return;

            //TeleLib = gameObject.AddComponent<TeleportableLib>();
            //Reset the state of ignored and added colliders
            if (_ignoredColliders != null)
            {
                foreach (Portal p in _ignoredColliders.Keys)
                {
                    ResumeAllCollision(p);
                }
            }

            if (Doppleganger)
            {
                Destroy(Doppleganger);
            }

            _ignoredColliders = new Dictionary <Portal, HashSet <Collider> >();
            _addedColliders   = new Dictionary <Portal, HashSet <Collider> >();

            Transforms          = new Dictionary <Transform, Transform>();
            Renderers           = new Dictionary <Renderer, Renderer>();
            SkinnedRenderers    = new HashSet <SkinnedMeshRenderer>();
            TeleportableScripts = new HashSet <TeleportableScript>();

            Colliders = new Dictionary <int, Collider>();
            if (!root)
            {
                root = transform;
            }
            StartCoroutine(SpawnDoppleganger());


#if VR_PORTALS
            interactable = gameObject.GetComponent <VRTK_InteractableObject>();
#endif
            _visOnly = VisOnly;

            //Doppleganger.ApplyHideFlagsRecursive(HideFlags.HideAndDontSave);
            UpdateBounds();
            TeleportableBounds.center = transform.position;
        }
コード例 #2
0
        public static void ApplyVR(bool includeVRTK)
        {
            EditorUtility.DisplayProgressBar("Applying VR Presets...", "", 1f);

            if (includeVRTK)
            {
                Logger.Log("Importing VRTK");
                EditorPrefs.SetInt(_importingVRTK, 2);

                var vrtkPath = Directory.GetFiles("Assets", "vrtk.unitypackage", SearchOption.AllDirectories);
                if (vrtkPath.Length > 0)
                {
                    AssetDatabase.ImportPackage(vrtkPath[0], false);
                    //AssetDatabase.Refresh();
                }
                else
                {
                    // failed to find vrtk package
                }
            }
            else
            {
                // if the user decides to set VR mode without importing VRTK the compile flags can cause errors/
                // detect those errors and let the user know the problem.
                if (!VRTKIsMaybeInstalled)
                {
                    ConsoleCallbackHandler.AddCallback(HandleVRTKImportError, LogType.Error, "CS0246");
                }
            }

            var vrtkSupportPath = Directory.GetFiles("Assets", "vrtk_support.unitypackage", SearchOption.AllDirectories);

            if (vrtkSupportPath.Length > 0)
            {
                AssetDatabase.ImportPackage(vrtkSupportPath[0], false);
                AssetDatabase.Refresh();
            }
            else
            {
                // failed to find vrtk_support package
            }

            EditorPrefs.SetBool(_performingSetup, true);
            if (!projectInitialized)
            {
                PerformFirstTimeSetup();
            }

            SKSEditorUtil.AddDefine(vrSymbol);
        }
コード例 #3
0
        private void OnEnable()
        {
            _colliders = new Dictionary <int, Collider>();

#if UNITY_EDITOR
            ConsoleCallbackHandler.AddCallback(() => {
                Dependencies.RescanDictionary();
                StartCoroutine(ConsoleTheConsole());
            }, LogType.Error, "Can't remove");
            if (PrefabUtility.GetPrefabParent(gameObject) == null &&
                PrefabUtility.GetPrefabObject(gameObject) != null)
            {
                return;
            }
#endif

            if (Doppleganger)
            {
                Destroy(Doppleganger);
            }

            if (_doppleDisabler)
            {
                Destroy(_doppleDisabler);
            }

            _doppleDisabler = new GameObject("Doppleganger Disabler (temp)");
            _doppleDisabler.SetActive(false);

            Transforms          = new Dictionary <Transform, Transform>();
            Renderers           = new Dictionary <Renderer, Renderer>();
            SkinnedRenderers    = new HashSet <SkinnedMeshRenderer>();
            TeleportableScripts = new HashSet <TeleportableScript>();

            if (!Root)
            {
                Root = transform;
            }

            StartCoroutine(SpawnDoppleganger());
#if VR_PORTALS
            interactable = gameObject.GetComponent <VRTK_InteractableObject>();
#endif
            _visOnly = VisOnly;
#if !SKS_DEV
            Doppleganger.ApplyHideFlagsRecursive(HideFlags.HideAndDontSave);
#endif
            UpdateBounds();
            TeleportableBounds.center = transform.position;
        }
コード例 #4
0
        private static void HandleVRTKImportError()
        {
            ConsoleCallbackHandler.RemoveCallback(LogType.Error, "CS0246");
            EditorUtility.ClearProgressBar();

            EditorUtility.DisplayDialog("No VRTK Installation Found", "No suitable VRTK installation found. VR Portal scripts will not function and may throw errors if VRTK is not present.\n\nIf you have no existing VRTK installation, you should check the 'Also import VRTK' box before applying VR mode.", "Okay");

            SKSEditorUtil.RemoveDefine(vrSymbol);
            performingSetup = false;

            if (performingFirstRunSetup)
            {
                SKSEditorUtil.RemoveDefine(projectSymbol);
                performingFirstRunSetup = false;
            }
        }