コード例 #1
0
ファイル: Utils.cs プロジェクト: Screwable/VRChat-Mods
        public static Vector3 GetWorldCameraPosition()
        {
            VRCVrCamera camera = GetVRCVrCamera();
            var         type   = camera.GetIl2CppType();

            if (type == Il2CppType.Of <VRCVrCameraSteam>())
            {
                VRCVrCameraSteam steam      = camera.Cast <VRCVrCameraSteam>();
                Transform        transform1 = steam.field_Private_Transform_0;
                Transform        transform2 = steam.field_Private_Transform_1;
                if (transform1.name == "Camera (eye)")
                {
                    return(transform1.position);
                }
                else if (transform2.name == "Camera (eye)")
                {
                    return(transform2.position);
                }
            }
            else if (type == Il2CppType.Of <VRCVrCameraUnity>())
            {
                VRCVrCameraUnity unity = camera.Cast <VRCVrCameraUnity>();
                return(unity.CameraStereo.transform.position);
            }
            else if (type == Il2CppType.Of <VRCVrCameraWave>())
            {
                VRCVrCameraWave wave = camera.Cast <VRCVrCameraWave>();
                return(wave.transform.position);
            }
            return(camera.transform.parent.TransformPoint(GetLocalCameraPosition()));
        }
コード例 #2
0
ファイル: Utils.cs プロジェクト: Screwable/VRChat-Mods
        public static Vector3 GetLocalCameraPosition()
        {
            VRCVrCamera camera = GetVRCVrCamera();
            var         type   = camera.GetIl2CppType();

            if (type == Il2CppType.Of <VRCVrCameraGoogle>())
            {
                return(camera.transform.localPosition);
            }
            else if (type == Il2CppType.Of <VRCVrCameraSteam>())
            {
                VRCVrCameraSteam steam      = camera.Cast <VRCVrCameraSteam>();
                Transform        transform1 = steam.field_Private_Transform_0;
                Transform        transform2 = steam.field_Private_Transform_1;
                if (transform1.name == "Camera (eye)")
                {
                    return(camera.transform.parent.InverseTransformPoint(transform1.position));
                }
                else if (transform2.name == "Camera (eye)")
                {
                    return(camera.transform.parent.InverseTransformPoint(transform2.position));
                }
                else
                {
                    return(Vector3.zero);
                }
            }
            else if (type == Il2CppType.Of <VRCVrCameraUnity>())
            {
                if (IsInVR())
                {
                    return(camera.transform.localPosition + InputTracking.GetLocalPosition(XRNode.CenterEye));
                }
                VRCVrCameraUnity unity = camera.Cast <VRCVrCameraUnity>();
                return(camera.transform.parent.InverseTransformPoint(unity.CameraStereo.transform.position));
            }
            else if (type == Il2CppType.Of <VRCVrCameraWave>())
            {
                VRCVrCameraWave wave = camera.Cast <VRCVrCameraWave>();
                return(wave.trackingRoot.InverseTransformPoint(camera.transform.position));
            }
            return(Vector3.zero);
        }