示例#1
0
    private void Awake()
    {
        VRView.viewerPivot.parent = transform;         // Parent the camera pivot under EditorVR
        if (VRSettings.loadedDeviceName == "OpenVR")
        {
            // Steam's reference position should be at the feet and not at the head as we do with Oculus
            VRView.viewerPivot.localPosition = Vector3.zero;
        }
        InitializePlayerHandle();
        CreateDefaultActionMapInputs();
        CreateAllProxies();
        CreateDeviceDataForInputDevices();
        CreateEventSystem();

        m_PixelRaycastModule            = U.Object.AddComponent <PixelRaycastModule>(gameObject);
        m_PixelRaycastModule.ignoreRoot = transform;
        m_HighlightModule       = U.Object.AddComponent <HighlightModule>(gameObject);
        m_ObjectPlacementModule = U.Object.AddComponent <ObjectPlacementModule>(gameObject);

        m_AllTools          = U.Object.GetImplementationsOfInterface(typeof(ITool));
        m_AllWorkspaceTypes = U.Object.GetExtensionsOfClass(typeof(Workspace));

        // TODO: Only show tools in the menu for the input devices in the action map that match the devices present in the system.
        // This is why we're collecting all the action maps. Additionally, if the action map only has a single hand specified,
        // then only show it in that hand's menu.
        // CollectToolActionMaps(m_AllTools);
    }
    void Start()
    {
        stateInformation = new StateInformation();
        interfaceManager = InterfaceManager.GetInstance();
        prefabsManager   = PrefabsManager.GetInstance();
        levelController  = LevelController.instance;
        levelDataManager = LevelDataManager.GetInstance();

        startupModule           = (IStartupModule)StartupModule.GetInstance();
        objectDeletionModule    = (IObjectDeletionModule)ObjectDeletionModule.GetInstance();
        objectPlacementModule   = (IObjectPlacementModule)ObjectPlacementModule.GetInstance();
        objectEditingModule     = (IObjectEditingModule)ObjectEditingModule.GetInstance();
        objectInformationModule = (IObjectInformationModule)ObjectInformationModule.GetInstance();


        GameObject leftMouseButtonObject = Instantiate(mouseButtonPrefab, transform);

        leftMouseButton = leftMouseButtonObject.GetComponent <MouseButton>();
        GameObject rightMouseButtonObject = Instantiate(mouseButtonPrefab, transform);

        rightMouseButton = rightMouseButtonObject.GetComponent <MouseButton>();

        leftMouseButton.Setup(0, mouseButtonLeftPressedTime);
        rightMouseButton.Setup(1, cameraDragTime);

        prefabsManager.AddPrefabs();
        interfaceManager.SetupUI(prefabsManager.GetPrefabTable());

        InitializeLevel(initialLevelWidth, initialLevelHeight);
        SetupLevel();
    }
示例#3
0
        IEnumerator Start()
        {
            // Delay until at least one proxy initializes
            bool proxyActive = false;

            while (!proxyActive)
            {
                foreach (var proxy in m_Proxies)
                {
                    if (proxy.active)
                    {
                        proxyActive = true;
                        break;
                    }
                }

                yield return(null);
            }

            m_ControllersReady = true;

            if (m_ProxyExtras)
            {
                var extraData = m_ProxyExtras.data;
                ForEachRayOrigin((proxy, pair, device, deviceData) =>
                {
                    List <GameObject> prefabs;
                    if (extraData.TryGetValue(pair.Key, out prefabs))
                    {
                        foreach (var prefab in prefabs)
                        {
                            var go = InstantiateUI(prefab);
                            go.transform.SetParent(pair.Value, false);
                        }
                    }
                });
            }

            CreateSpatialSystem();

            m_ObjectPlacementModule = U.Object.AddComponent <ObjectPlacementModule>(gameObject);
            ConnectInterfaces(m_ObjectPlacementModule);

            SpawnActions();
            SpawnDefaultTools();
            AddPlayerModel();
            PrewarmAssets();

            // In case we have anything selected at start, set up manipulators, inspector, etc.
            EditorApplication.delayCall += OnSelectionChanged;

            // This will be the first call to update the player handle (input) maps, sorted by priority
            UpdatePlayerHandleMaps();
        }
 void Awake()
 {
     instance = this;
 }