コード例 #1
0
    /*************************************  Unity API ****************************************/
    #region Unity API

    void Awake()
    {
        PLOG.getConfigTraceLevel();
#if !UNITY_EDITOR && UNITY_ANDROID
        isViewerLogicFlow = ViewerLogicFlow();
        Debug.Log("viewer :" + isViewerLogicFlow.ToString());
        if (isViewerLogicFlow)
        {
            HeadDofNum = HeadDofNum.ThreeDof;
            HandDofNum = HandDofNum.ThreeDof;
        }
        else
        {
            int enumindex = (int)GlobalIntConfigs.TRACKING_MODE;
            Render.UPvr_GetIntConfig(enumindex, ref trackingmode);
            LoadIsPUIValue();
            if (isPUI)
            {
                if (trackingmode == 1 || trackingmode == 0)
                {
                    HeadDofNum = HeadDofNum.ThreeDof;
                    HandDofNum = HandDofNum.ThreeDof;
                }
            }
        }
#endif
        Application.targetFrameRate = 61;
#if !UNITY_EDITOR && UNITY_ANDROID
        int fps  = -1;
        int rate = (int)GlobalIntConfigs.TARGET_FRAME_RATE;
        Render.UPvr_GetIntConfig(rate, ref fps);
        float ffps  = 0.0f;
        int   frame = (int)GlobalFloatConfigs.DISPLAY_REFRESH_RATE;
        Render.UPvr_GetFloatConfig(frame, ref ffps);
        Application.targetFrameRate = fps > 0 ? fps : (int)ffps;
#endif

#if !UNITY_EDITOR && UNITY_ANDROID
        float neckx  = 0.0f;
        float necky  = 0.0f;
        float neckz  = 0.0f;
        int   modelx = (int)GlobalFloatConfigs.NECK_MODEL_X;
        int   modely = (int)GlobalFloatConfigs.NECK_MODEL_Y;
        int   modelz = (int)GlobalFloatConfigs.NECK_MODEL_Z;
        Render.UPvr_GetFloatConfig(modelx, ref neckx);
        Render.UPvr_GetFloatConfig(modely, ref necky);
        Render.UPvr_GetFloatConfig(modelz, ref neckz);
        if (neckx != 0.0f || necky != 0.0f || neckz != 0.0f)
        {
            neckOffset = new Vector3(neckx, necky, neckz);
        }
#endif
        var controllermanager = FindObjectOfType <Pvr_ControllerManager>();
        isHasController = controllermanager != null;
        if (sdk == null)
        {
            sdk = this;
        }
        if (sdk != this)
        {
            Debug.LogError("SDK object should be a singleton.");
            enabled = false;
            return;
        }
        if (SDKManagerInit())
        {
            Debug.Log("SDK Init success.");
        }
        else
        {
            Debug.LogError("SDK Init Failed.");
            Application.Quit();
        }

        SDKManagerInitFPS();

        safeArea   = transform.Find("SafeArea2").gameObject;
        safeToast  = transform.Find("SafeToast").gameObject;
        resetPanel = transform.Find("ResetPanel").gameObject;
        safePanel1 = transform.Find("SafePanel1").gameObject;
        safePanel2 = transform.Find("SafePanel2").gameObject;
        if (isViewerLogicFlow)
        {
            // Viewer battery
            InitViewerBatteryVolClass();
            ViewerToast = transform.Find("Head").Find("Viewertoast").gameObject;;
            if (safeArea != null)
            {
                DestroyObject(safeArea);
            }
            if (safeToast != null)
            {
                DestroyObject(safeToast);
            }
            if (resetPanel != null)
            {
                DestroyObject(resetPanel);
            }
            if (safePanel1 != null)
            {
                DestroyObject(safePanel1);
            }
            if (safePanel2 != null)
            {
                DestroyObject(safePanel2);
            }
        }
        else
        {
            if (Application.systemLanguage != SystemLanguage.Chinese && Application.systemLanguage != SystemLanguage.ChineseSimplified)
            {
                safeToast.transform.Find("Panel/title").GetComponent <Text>().text = "You have left the safe zone";
                safeToast.transform.Find("Panel/Text").GetComponent <Text>().text  = "Please take off your headset and return to the safe zone,or hold down the Home key of headset to rebuild a safe zone.";
                safeToast.transform.Find("Panel/Image").localPosition = new Vector3(15, -91, 0);
                safeToast.transform.Find("Panel/Text").GetComponent <RectTransform>().sizeDelta = new Vector2(370, 250);
                safeToast.transform.Find("Panel/Text").localPosition = new Vector3(15, -2, 0);
                safeToast.transform.Find("Panel/Text").GetComponent <Text>().lineSpacing        = 0.8f;
                resetPanel.transform.Find("Panel/resetbtn/Text").GetComponent <Text>().text     = "Continue";
                safePanel1.transform.Find("Panel/startgameBtn/Text").GetComponent <Text>().text = "Continue";
                safePanel2.transform.Find("Panel/Title").GetComponent <Text>().text             = "Warning";
                safePanel2.transform.Find("Panel/toast2").GetComponent <Text>().text            = "This device does not support this applications";
                safePanel2.transform.Find("Panel/forcequitBtn/Text").GetComponent <Text>().text = "Quit";
                safePanel1.transform.Find("Panel/Image").localPosition = new Vector3(0, -49, 0);
                safePanel1.transform.Find("Panel/toast1").GetComponent <RectTransform>().sizeDelta = new Vector2(370, 170);
                safePanel1.transform.Find("Panel/toast1").localPosition = new Vector3(13, 93, 0);
                safePanel1.transform.Find("Panel/toast1").GetComponent <Text>().lineSpacing = 0.8f;
                resetPanel.transform.Find("Panel/Image").localPosition = new Vector3(0, -53, 0);
                resetPanel.transform.Find("Panel/toast").GetComponent <RectTransform>().sizeDelta = new Vector2(370, 170);
                resetPanel.transform.Find("Panel/toast").localPosition = new Vector3(16, 88, 0);
                resetPanel.transform.Find("Panel/toast").GetComponent <Text>().lineSpacing = 0.8f;
                if (DefaultRange)
                {
                    resetPanel.transform.Find("Panel/toast").GetComponent <Text>().text =
                        "Please take off your headset and ensure that there are no obstacles within a radius of 0.8 meters,then press Continue";
                    safePanel1.transform.Find("Panel/toast1").GetComponent <Text>().text =
                        "Please take off your headset and ensure that there are no obstacles within a radius of 0.8 meters,then press Continue";
                }
                else
                {
                    resetPanel.transform.Find("Panel/toast").GetComponent <Text>().text =
                        "Please take off your headset and ensure that there are no obstacles within a radius of" + CustomRange + "meters,then press Continue";
                    safePanel1.transform.Find("Panel/toast1").GetComponent <Text>().text =
                        "Please take off your headset and ensure that there are no obstacles within a radius of" + CustomRange + "meters,then press Continue";
                }
            }
#if !UNITY_EDITOR && UNITY_ANDROID
            if (HeadDofNum == HeadDofNum.SixDof || HandDofNum == HandDofNum.SixDof)
            {
                if (trackingmode == 1 || trackingmode == 0)
                {
                    safePanel2.SetActive(true);
                }
            }
            if (HeadDofNum == HeadDofNum.SixDof)
            {
                if (Sensor.Pvr_IsHead6dofReset() && ShowSafePanel)
                {
                    safePanel1.SetActive(true);
                }
            }
#endif
        }
    }
コード例 #2
0
    /*************************************  Unity API ****************************************/

    #region Unity API

    void Awake()
    {
#if ANDROID_DEVICE
        Debug.Log("DISFT Unity Version:" + Application.unityVersion);
        Debug.Log("DISFT Customize NeckOffset:" + neckOffset);
        Debug.Log("DISFT MSAA :" + Pvr_UnitySDKProjectSetting.GetProjectConfig().rtAntiAlising.ToString());
        if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset != null)
        {
            Debug.Log("DISFT LWRP = Enable");
        }
        Debug.Log("DISFT Content Proctect :" + Pvr_UnitySDKProjectSetting.GetProjectConfig().usecontentprotect.ToString());

        int isrot = 0;
        int rot   = 0;
        LoadIsMirroringValue();
        if (!ismirroring)
        {
            rot = (int)GlobalIntConfigs.Enable_Activity_Rotation;
            Render.UPvr_GetIntConfig(rot, ref isrot);
            if (isrot == 1)
            {
                Debug.Log("DISFT ScreenOrientation.Portrait = Enable");
                Screen.orientation = ScreenOrientation.Portrait;
            }
        }
        else
        {
            rot = (int)GlobalIntConfigs.GetDisplay_Orientation;
            Render.UPvr_GetIntConfig(rot, ref isrot);
            Screen.orientation = isrot == 0 ? ScreenOrientation.Portrait : ScreenOrientation.LandscapeLeft;
        }
#endif

#if ANDROID_DEVICE
        var javaVrActivityClass = new AndroidJavaClass("com.psmart.vrlib.VrActivity");
        var unityPlayer         = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        var activity            = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
#endif
        var controllermanager = FindObjectOfType <Pvr_ControllerManager>();
        isHasController = controllermanager != null;
        PLOG.getConfigTraceLevel();

        int enumindex = (int)GlobalIntConfigs.TRACKING_MODE;
        Render.UPvr_GetIntConfig(enumindex, ref trackingmode);
        //setting of fps
        Application.targetFrameRate = 61;
#if ANDROID_DEVICE
        int ability6dof = 0;
        enumindex = (int)Pvr_UnitySDKAPI.GlobalIntConfigs.ABILITY6DOF;
        Pvr_UnitySDKAPI.Render.UPvr_GetIntConfig(enumindex, ref ability6dof);
        if (ability6dof == 0)
        {
            SDK.HmdOnlyrot = true;
        }
        int fps  = -1;
        int rate = (int)GlobalIntConfigs.TARGET_FRAME_RATE;
        Render.UPvr_GetIntConfig(rate, ref fps);
        float ffps  = 0.0f;
        int   frame = (int)GlobalFloatConfigs.DISPLAY_REFRESH_RATE;
        Render.UPvr_GetFloatConfig(frame, ref ffps);
        Application.targetFrameRate = fps > 0 ? fps : (int)ffps;

        if (!Pvr_UnitySDKProjectSetting.GetProjectConfig().usedefaultfps)
        {
            if (Pvr_UnitySDKProjectSetting.GetProjectConfig().customfps <= ffps)
            {
                Application.targetFrameRate = Pvr_UnitySDKProjectSetting.GetProjectConfig().customfps;
            }
            else
            {
                Application.targetFrameRate = (int)ffps;
            }
        }
        Debug.Log("DISFT Customize FPS :" + Application.targetFrameRate);
#endif

        //setting of neck model
#if ANDROID_DEVICE
        if (!UseCustomNeckPara)
        {
            float neckx  = 0.0f;
            float necky  = 0.0f;
            float neckz  = 0.0f;
            int   modelx = (int)GlobalFloatConfigs.NECK_MODEL_X;
            int   modely = (int)GlobalFloatConfigs.NECK_MODEL_Y;
            int   modelz = (int)GlobalFloatConfigs.NECK_MODEL_Z;
            Render.UPvr_GetFloatConfig(modelx, ref neckx);
            Render.UPvr_GetFloatConfig(modely, ref necky);
            Render.UPvr_GetFloatConfig(modelz, ref neckz);
            if (neckx != 0.0f || necky != 0.0f || neckz != 0.0f)
            {
                neckOffset = new Vector3(neckx, necky, neckz);
            }
        }
#endif
        Render.UPvr_GetIntConfig((int)GlobalIntConfigs.iPhoneHMDModeEnabled, ref iPhoneHMDModeEnabled);

        Pvr_ControllerManager.ControllerStatusChangeEvent += CheckControllerStateForG2;
#if ANDROID_DEVICE
        InitUI();
        RefreshTextByLanguage();
#endif
    }
コード例 #3
0
    /*************************************  Unity API ****************************************/
    #region Unity API

    void Awake()
    {
        PLOG.getConfigTraceLevel();
#if !UNITY_EDITOR && UNITY_ANDROID
        int enumindex = (int)GlobalIntConfigs.TRACKING_MODE;
        Render.UPvr_GetIntConfig(enumindex, ref trackingmode);
        if (isPUI)
        {
            if (trackingmode == 1 || trackingmode == 0)
            {
                HeadDofNum = HeadDofNum.ThreeDof;
                HandDofNum = HandDofNum.ThreeDof;
                HandNum    = HandNum.One;
            }
        }
#endif
        Application.targetFrameRate = 61;
#if !UNITY_EDITOR && UNITY_ANDROID
        int fps  = -1;
        int rate = (int)GlobalIntConfigs.TARGET_FRAME_RATE;
        Render.UPvr_GetIntConfig(rate, ref fps);
        float ffps  = 0.0f;
        int   frame = (int)GlobalFloatConfigs.DISPLAY_REFRESH_RATE;
        Render.UPvr_GetFloatConfig(frame, ref ffps);
        Application.targetFrameRate = fps > 0 ? fps : (int)ffps;
#endif

#if !UNITY_EDITOR && UNITY_ANDROID
        float neckx  = 0.0f;
        float necky  = 0.0f;
        float neckz  = 0.0f;
        int   modelx = (int)GlobalFloatConfigs.NECK_MODEL_X;
        int   modely = (int)GlobalFloatConfigs.NECK_MODEL_Y;
        int   modelz = (int)GlobalFloatConfigs.NECK_MODEL_Z;
        Render.UPvr_GetFloatConfig(modelx, ref neckx);
        Render.UPvr_GetFloatConfig(modely, ref necky);
        Render.UPvr_GetFloatConfig(modelz, ref neckz);
        if (neckx != 0.0f || necky != 0.0f || neckz != 0.0f)
        {
            neckOffset = new Vector3(neckx, necky, neckz);
        }
#endif
        var controllermanager = FindObjectOfType <Pvr_ControllerManager>();
        isHasController = controllermanager != null;
        if (sdk == null)
        {
            sdk = this;
        }
        if (sdk != this)
        {
            Debug.LogError("SDK object should be a singleton.");
            enabled = false;
            return;
        }
        if (SDKManagerInit())
        {
            Debug.Log("SDK Init success.");
        }
        else
        {
            Debug.LogError("SDK Init Failed.");
            Application.Quit();
        }

        SDKManagerInitFPS();

        //    safeArea = transform.Find("SafeArea2").gameObject;
        //safeToast = transform.Find("Head/SafeToast").gameObject;
        /// resetPanel = transform.Find("ResetPanel").gameObject;
        // safePanel1 = transform.Find("SafePanel1").gameObject;
        // safePanel2 = transform.Find("SafePanel2").gameObject;

        if (Application.systemLanguage != SystemLanguage.Chinese && Application.systemLanguage != SystemLanguage.ChineseSimplified)
        {
            safeToast.transform.Find("title").GetComponent <Text>().text = "Safety Warning";
            safeToast.transform.Find("Text").GetComponent <Text>().text  =
                "You have left the safe zone. Please take off your headset and return to the safe zone,or hold down the Home key of headset to rebuild a safe zone.";
            resetPanel.transform.Find("Panel/resetbtn/Text").GetComponent <Text>().text     = "Continue";
            safePanel1.transform.Find("Panel/startgameBtn/Text").GetComponent <Text>().text = "Continue";
            safePanel1.transform.Find("Panel/toast2").GetComponent <Text>().text            = "I have read and agree to the ";
            safePanel1.transform.Find("Panel/toast3").GetComponent <Text>().text            = "safety policy.";
            safePanel1.transform.Find("Panel/Toggle").localPosition                         = new Vector3(-37, -136, 0);
            safePanel2.transform.Find("Panel/Title").GetComponent <Text>().text             = "Warning";
            safePanel2.transform.Find("Panel/toast2").GetComponent <Text>().text            = "This device does not support this applications";
            safePanel2.transform.Find("Panel/forcequitBtn/Text").GetComponent <Text>().text = "Quit";
            if (DefaultRange)
            {
                resetPanel.transform.Find("Panel/toast").GetComponent <Text>().text =
                    "Please take off your headset and ensure that there are no obstacles within a radius of 0.8 meters,then press Continue";
                safePanel1.transform.Find("Panel/toast1").GetComponent <Text>().text =
                    "Please take off your headset and ensure that there are no obstacles within a radius of 0.8 meters,then press Continue";
            }
            else
            {
                resetPanel.transform.Find("Panel/toast").GetComponent <Text>().text =
                    "Please take off your headset and ensure that there are no obstacles within a radius of" + CustomRange + "meters,then press Continue";
                safePanel1.transform.Find("Panel/toast1").GetComponent <Text>().text =
                    "Please take off your headset and ensure that there are no obstacles within a radius of" + CustomRange + "meters,then press Continue";
            }
        }
#if !UNITY_EDITOR && UNITY_ANDROID
        if (HeadDofNum == HeadDofNum.SixDof || HandDofNum == HandDofNum.SixDof)
        {
            if (trackingmode == 1 || trackingmode == 0)
            {
                safePanel2.SetActive(true);
            }
        }
        if (ShowSafePanel && HeadDofNum == HeadDofNum.SixDof && Sensor.UPvr_Pvr_Get6DofSafePanelFlag())
        {
            safePanel1.SetActive(true);
            var toggle = safePanel1.transform.Find("Panel/Toggle").GetComponent <Toggle>();
            toggle.isOn = false;
            toggle.onValueChanged.AddListener(ToggleValueChange);
            safePanel1.transform.Find("Panel/startgameBtn").GetComponent <Button>().interactable = false;
        }
#endif
    }