Inheritance: MonoBehaviour
Esempio n. 1
0
        public void Start()
        {
            if (!UIManager.IsAlive)
            {
                Debug.LogWarning("There is no UIManager in the scene, so SetHandednessEvent may not work properly.");
            }

            _manager = UIManager.Instance;

            playerRefs.LeftHandSwitchMenuAction.onFirstClick.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("menu.setLeftHanded");

                KomodoEventManager.TriggerEvent("tools.setRightHanded");
            });

            playerRefs.RightHandSwitchMenuAction.onFirstClick.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("menu.setRightHanded");

                KomodoEventManager.TriggerEvent("tools.setLeftHanded");
            });

            KomodoEventManager.TriggerEvent("menu.setScreen");

            KomodoEventManager.TriggerEvent("tools.setScreen");

            _wasInVRLastFrame = false;
        }
Esempio n. 2
0
        public void Update()
        {
            // This is a hack! Until ToggleMenuDisplayMode is updated to allow
            // callbacks for the functions SetVRViewPort and
            // SetDesktopViewport, we must continually check to see which
            // rendering mode the menu is in to infer whether we're in VR or on
            // a Screen. Otherwise, we must reference the WebXR assembly
            // directly.

            bool isInVRThisFrame = _manager.menuCanvas.renderMode == RenderMode.WorldSpace;

            if (_wasInVRLastFrame && !isInVRThisFrame)
            {
                // Switch to Screen mode.

                KomodoEventManager.TriggerEvent("menu.setScreen");

                KomodoEventManager.TriggerEvent("tools.setScreen");

                _wasInVRLastFrame = false;
            }

            if (!_wasInVRLastFrame && isInVRThisFrame)
            {
                // Switch to VR mode.

                KomodoEventManager.TriggerEvent("menu.setLeftHanded");

                KomodoEventManager.TriggerEvent("tools.setRightHanded");

                _wasInVRLastFrame = true;
            }
        }
        public void Start()
        {
            if (leftHandedMenuAnchor == null)
            {
                throw new UnassignedReferenceException("leftHandedMenuAnchor");
            }

            if (rightHandedMenuAnchor == null)
            {
                throw new UnassignedReferenceException("rightHandedMenuAnchor");
            }

            if (screenMenuAnchor == null)
            {
                throw new UnassignedReferenceException("screenMenuAnchor");
            }

            _currentKind = MenuAnchor.Kind.UNKNOWN;

            KomodoEventManager.StartListening("menu.setRightHanded", () =>
            {
                SetCurrentMenuAnchor(MenuAnchor.Kind.RIGHT_HANDED);
            });

            KomodoEventManager.StartListening("menu.setLeftHanded", () =>
            {
                SetCurrentMenuAnchor(MenuAnchor.Kind.LEFT_HANDED);
            });

            KomodoEventManager.StartListening("menu.setScreen", () =>
            {
                SetCurrentMenuAnchor(MenuAnchor.Kind.SCREEN);
            });
        }
        public static void Deinitialize()
        {
            KomodoEventManager.StopListening("capture.start", startCapture);
            KomodoEventManager.StopListening("capture.stop", stopCapture);

            startCapture -= Start_Record;
            stopCapture  -= End_Record;
        }
        public static void Initialize()
        {
            startCapture += Start_Record;
            stopCapture  += End_Record;

            KomodoEventManager.StartListening("capture.start", startCapture);
            KomodoEventManager.StartListening("capture.stop", stopCapture);
        }
Esempio n. 6
0
        public void Start()
        {
            CaptureManager.Initialize();

            eraseTab.onTabSelected.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("eraseTool.enable");
            });

            eraseTab.onTabDeselected.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("eraseTool.disable");
            });

            undoButton.onClick.AddListener(() =>
            {
                UndoRedoManager.Instance.Undo();
            });

            drawTab.onTabSelected.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("drawTool.enable");
            });

            drawTab.onTabDeselected.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("drawTool.disable");

                KomodoEventManager.TriggerEvent("primitiveTool.disable");
            });

            brushToggle.onValueChanged.AddListener((isOn) =>
            {
                if (isOn)
                {
                    KomodoEventManager.TriggerEvent("drawTool.enable");

                    KomodoEventManager.TriggerEvent("primitiveTool.disable");

                    // TODO(Brandon) - is this the best way to get out of the primitive creation mode?

                    return;
                }

                KomodoEventManager.TriggerEvent("drawTool.disable");
            });

            leaveAndRejoinButton.onClick.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("connection.leaveAndRejoin");
            });

            closeConnectionAndRejoinButton.onClick.AddListener(() =>
            {
                KomodoEventManager.TriggerEvent("connection.closeConnectionAndRejoin");
            });
        }
Esempio n. 7
0
        void Start()
        {
            _enable += Enable;

            KomodoEventManager.StartListening("drawTool.enable", _enable);

            _disable += Disable;

            KomodoEventManager.StartListening("drawTool.disable", _disable);
        }
        public void UpdatePlayerPosition2(Position newData)
        {
            if (teleportationCount >= 2)
            {
                KomodoEventManager.TriggerEvent("TeleportedTwice");
            }
            UpdateCenterEye();

            UpdatePlayerXZPosition(newData.pos.x, newData.pos.z);

            UpdatePlayerYPosition(newData.pos.y);

            teleportationCount += 1;
        }
        public void Start()
        {
            KomodoEventManager.StartListening("tools.setRightHanded", () =>
            {
                SetCurrentToolAnchor(ToolAnchor.Kind.RIGHT_HANDED);
            });

            KomodoEventManager.StartListening("tools.setLeftHanded", () =>
            {
                SetCurrentToolAnchor(ToolAnchor.Kind.LEFT_HANDED);
            });

            KomodoEventManager.StartListening("tools.setScreen", () =>
            {
                SetCurrentToolAnchor(ToolAnchor.Kind.SCREEN);
            });
        }
Esempio n. 10
0
        public void Start()
        {
            if (socketIODisplay == null)
            {
                Debug.LogError("socketIODisplay Text component was not assigned in ConnectionAdapter");
            }

            NetworkUpdateHandler netHandler = NetworkUpdateHandler.Instance;

            KomodoEventManager.StartListening("connection.leaveAndRejoin", () =>
            {
                SocketIOAdapter.Instance.LeaveAndRejoin();
            });

            KomodoEventManager.StartListening("connection.closeConnectionAndRejoin", () =>
            {
                SocketIOAdapter.Instance.CloseConnectionAndRejoin();
            });
        }
Esempio n. 11
0
 public void Start()
 {
     recordButtons.onClick.AddListener(() =>
     {
         if (startCapture.activeSelf)
         {
             KomodoEventManager.TriggerEvent("capture.start");
             recordButtons.transform.Find("startCapture").gameObject.SetActive(false);
             recordButtons.transform.Find("stopCapture").gameObject.SetActive(true);
         }
         else if (!startCapture.activeSelf)
         {
             KomodoEventManager.TriggerEvent("capture.stop");
             recordButtons.transform.Find("startCapture").gameObject.SetActive(true);
             recordButtons.transform.Find("stopCapture").gameObject.SetActive(false);
         }
         else
         {
             return;
         }
     });
 }
        public void EndCalibration()
        {
            if (!isCalibratingHeight)
            {
                return;
            }

            var handHeight = minYOfHands;

            var terrainHeight = ComputeGlobalYPositionOfTerrainBelowPlayer();

            var heightToBumpPlayer = terrainHeight - handHeight;

            //Debug.Log($"[HeightCalibration] terrain height: {terrainHeight} / handHeight: {handHeight} / heightToBumpPlayer: {heightToBumpPlayer}");

            onFinishedCalibration.Invoke(heightToBumpPlayer);

            KomodoEventManager.TriggerEvent("FinishedHeightCalibration");

            minYOfHands = float.MaxValue;

            isCalibratingHeight = false;
        }
Esempio n. 13
0
 void Start()
 {
     KomodoEventManager.TriggerEvent("MandatoryHeightCalibration");
 }
Esempio n. 14
0
        public void Start()
        {
            if (!menuPlacement)
            {
                throw new UnassignedReferenceException("menuPlacement");
            }

            if (!colorImageObject)
            {
                throw new UnassignedReferenceException("colorImageObject");
            }

            colorRectTransform = colorImageObject.GetComponent <RectTransform>();

            if (colorRectTransform == null)
            {
                throw new MissingComponentException("RectTransform on colorImageObject");
            }

            RawImage colorImage = colorImageObject.GetComponent <RawImage>();

            if (colorImage == null)
            {
                throw new MissingComponentException("RawImage on colorImageObject");
            }

            colorTexture = (Texture2D)colorImage.texture;

            if (!colorTexture)
            {
                throw new MissingReferenceException("texture in colorImage");
            }

            foreach (var lineRenderer in lineRenderers)
            {
                var triggerDraw = lineRenderer.GetComponent <TriggerDraw>();

                if (triggerDraw == null)
                {
                    Debug.LogError("There is no TriggerDraw.cs in Color Tool LineRenderer ", gameObject);

                    continue;
                }

                triggers.Add(triggerDraw);
            }

            if (!selectedColorCursor.transform)
            {
                throw new MissingFieldException("transform on selectedColorCursor");
            }

            if (!previewColorCursor.transform)
            {
                throw new MissingFieldException("transform on previewColorCursor");
            }

            previewColorCursorRectTransform = previewColorCursor.GetComponent <RectTransform>();

            if (!previewColorCursorRectTransform)
            {
                throw new MissingComponentException("RectTransform on previewColorCursor");
            }

            selectedColorCursorRectTransform = selectedColorCursor.GetComponent <RectTransform>();

            if (!selectedColorCursorRectTransform)
            {
                throw new MissingComponentException("RectTransform on selectedColorCursor");
            }

            TryGrabPlayerDrawTargets();

            _enable += Enable;

            KomodoEventManager.StartListening("drawTool.enable", _enable);

            _disable += Disable;

            KomodoEventManager.StartListening("drawTool.disable", _disable);
        }
Esempio n. 15
0
 void OnDisable()
 {
     KomodoEventManager.StopListening("MandatoryHeightCalibration", ShowCalibrationPromptListener);
     KomodoEventManager.StopListening("FinishedHeightCalibration", HideCalibrationPromptListener);
     KomodoEventManager.StopListening("TeleportedTwice", TeleportationCountListener);
 }