コード例 #1
0
        private IEnumerator EnableScripts()
        {
            while (!this.isNameSet)
            {
                yield return(null);
            }

            if (this.photonView.IsMine)
            {
                this.GetComponent <GraspingDetectorForPun>().enabled = true;

                this.GetComponent <AudioListener>().enabled = true;

                this.GetComponent <HsrChat>().enabled = true;

                this.rosBridgeScripts.SetActive(true);

                PunLauncher.EnableSubview(this.gameObject);
            }
            else
            {
                Rigidbody[] rigidbodies = this.GetComponentsInChildren <Rigidbody>(true);

                foreach (Rigidbody rigidbody in rigidbodies)
                {
                    rigidbody.useGravity = false;
//					rigidbody.isKinematic = true;
                }
            }
        }
コード例 #2
0
        void Start()
        {
            PhotonView photonView = this.GetComponent <PhotonView>();

            StartCoroutine(this.SetAvatarName(photonView));

            if (photonView.IsMine)
            {
                this.GetComponent <HumanAvatarChat>().enabled = true;

                this.ovrCameraRig.GetComponent <OVRCameraRig>().enabled = true;

                this.ovrCameraRig.GetComponent <OVRManager>().enabled = true;

                this.ovrCameraRig.GetComponent <SIGVerse.Human.IK.AnchorPostureCalculator>().enabled = true;

                this.centerEyeAnchor.GetComponent <Camera>().enabled = true;

                this.ethan.GetComponent <SimpleHumanVRControllerForPun>().enabled = true;

                CleanupAvatarVRHandControllerForRift[] cleanupAvatarVRHandControllerForRiftList = this.ethan.GetComponents <CleanupAvatarVRHandControllerForRift>();

                foreach (CleanupAvatarVRHandControllerForRift cleanupAvatarVRHandControllerForRift in cleanupAvatarVRHandControllerForRiftList)
                {
                    cleanupAvatarVRHandControllerForRift.enabled = true;
                }

                PunLauncher.EnableSubview(this.gameObject);
            }
            else
            {
                this.centerEyeAnchor.GetComponent <Camera>().enabled = false;
            }
        }
コード例 #3
0
        private IEnumerator EnableScripts()
        {
            while (!this.isNameSet)
            {
                yield return(null);
            }

            if (this.photonView.IsMine)
            {
                this.GetComponent <HumanAvatarChat>().enabled = true;

                this.GetComponent <Player>().enabled = true;

//				this.cameraRig.GetComponent<SteamVR_PlayArea>().enabled = true;

                this.cameraRig.GetComponent <SIGVerse.Human.IK.AnchorPostureCalculator>().enabled = true;

                SteamVR_Behaviour_Pose[] steamVrBehaviourPoses = this.cameraRig.GetComponentsInChildren <SteamVR_Behaviour_Pose>();

                foreach (SteamVR_Behaviour_Pose steamVrBehaviourPose in steamVrBehaviourPoses)
                {
                    steamVrBehaviourPose.enabled = true;
                }

                Hand[] hands = this.cameraRig.GetComponentsInChildren <Hand>(true);

                foreach (Hand hand in hands)
                {
                    hand.enabled = true;
                }

                this.eyeAnchor.GetComponent <Camera>().enabled = true;

                this.eyeAnchor.GetComponent <AudioListener>().enabled = true;

                this.eyeAnchor.GetComponent <SteamVR_CameraHelper>().enabled = true;

                this.ethan.GetComponent <SimpleHumanVRControllerForPun>().enabled = true;

                this.EnableCleanupAvatarVRHandControllerForSteamVR();

                PunLauncher.EnableSubview(this.gameObject);
            }
            else
            {
                Rigidbody[] rigidbodies = this.GetComponentsInChildren <Rigidbody>(true);

                foreach (Rigidbody rigidbody in rigidbodies)
                {
                    rigidbody.useGravity = false;
//					rigidbody.isKinematic = true;
                }

                this.EnableCleanupAvatarVRHandControllerForSteamVR();
            }
        }
コード例 #4
0
        private void RemoveScripts <T>() where T : Component
        {
            PunLauncher punLauncher = (PunLauncher)target;

            foreach (GameObject sourceOfSyncTarget in punLauncher.rootsOfSyncTarget)
            {
                T[] photonScripts = sourceOfSyncTarget.GetComponentsInChildren <T>();

                foreach (T photonScript in photonScripts)
                {
                    Undo.DestroyObjectImmediate(photonScript);
                }
            }
        }
コード例 #5
0
        void Start()
        {
            PhotonView photonView = this.GetComponent <PhotonView>();

            StartCoroutine(this.SetAvatarName(photonView));

            if (photonView.IsMine)
            {
                this.GetComponent <GraspingDetectorForPun>().enabled = true;

                this.GetComponent <HsrChat>().enabled = true;

                this.rosBridgeScripts.SetActive(true);

                PunLauncher.EnableSubview(this.gameObject);
            }
        }
コード例 #6
0
        //void OnEnable()
        //{
        //}

        public override void OnInspectorGUI()
        {
            PunLauncher punLauncher = (PunLauncher)target;

            if (punLauncher.humanMaxNumber != punLauncher.humanPositions.Length || punLauncher.humanMaxNumber != punLauncher.humanEulerAngles.Length)
            {
                Undo.RecordObject(target, "Update Human Spawn Info");
                Array.Resize(ref punLauncher.humanPositions, punLauncher.humanMaxNumber);
                Array.Resize(ref punLauncher.humanEulerAngles, punLauncher.humanMaxNumber);
            }

            if (punLauncher.robotMaxNumber != punLauncher.robotPositions.Length || punLauncher.robotMaxNumber != punLauncher.robotEulerAngles.Length)
            {
                Undo.RecordObject(target, "Update Robot Spawn Info");
                Array.Resize(ref punLauncher.robotPositions, punLauncher.robotMaxNumber);
                Array.Resize(ref punLauncher.robotEulerAngles, punLauncher.robotMaxNumber);
            }

            base.OnInspectorGUI();

            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Update Photon View", GUILayout.Width(200), GUILayout.Height(40)))
                {
                    Undo.RecordObject(target, "Update Photon View");

                    // Remove photon scripts
                    RemoveScripts <PhotonTransformView>();
                    RemoveScripts <LocalTransformView>();
                    RemoveScripts <PhotonRigidbodyView>();
                    RemoveScripts <PhotonView>();
                    RemoveScripts <PunOwnerChangerForObject>();

                    // Add photon scripts
                    List <GameObject> roomObjects = new List <GameObject>();

                    foreach (GameObject sourceOfSyncTarget in punLauncher.rootsOfSyncTarget)
                    {
                        Rigidbody[] syncTargetRigidbodies = sourceOfSyncTarget.GetComponentsInChildren <Rigidbody>();

                        foreach (Rigidbody syncTargetRigidbody in syncTargetRigidbodies)
                        {
                            roomObjects.Add(syncTargetRigidbody.gameObject);
                        }
                    }

                    punLauncher.SetRoomObjects(roomObjects);

                    foreach (GameObject roomObject in roomObjects)
                    {
                        PhotonView photonView = Undo.AddComponent <PhotonView>(roomObject);
                        photonView.OwnershipTransfer  = OwnershipOption.Takeover;
                        photonView.Synchronization    = ViewSynchronization.ReliableDeltaCompressed;
                        photonView.ObservedComponents = new List <Component>();

//						PhotonTransformView photonTransformView = Undo.AddComponent<PhotonTransformView>(roomObject);
                        LocalTransformView localTransformView = Undo.AddComponent <LocalTransformView>(roomObject);
//						PhotonRigidbodyView photonRigidbodyView = Undo.AddComponent<PhotonRigidbodyView>(roomObject);

//						photonView.ObservedComponents.Add(photonTransformView);
                        photonView.ObservedComponents.Add(localTransformView);
//						photonView.ObservedComponents.Add(photonRigidbodyView);

                        Undo.AddComponent <PunOwnerChangerForObject>(roomObject);
                    }
                }

                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
        }