Beispiel #1
0
    void Awake()
    {
        m_bResetTextureId = true;
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_Init("C3845343263589043", "3908040197953231", "8b20789122bae89442edadf780250ad5", "www.mojing.cn");

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
            MojingSDK.Unity_SetGamePadAxisMode(0);

            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            CreateDummyCamera();
            Application.targetFrameRate = 60;
            //MojingRender.StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");
            foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList)
            {
                product_list = MojingSDK.GetProducts(MI.KEY, "zh");
                foreach (ProductInfo PI in product_list.ProductList)
                {
                    glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh");
                    foreach (GlassInfo GI in glasses_list.GlassList)
                    {
                        string GlassName = MI.Display + " " + PI.Display + " " + GI.Display;
                        string GlassKey  = GI.KEY;
                        glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }
        MojingLog.LogTrace("Leave Mojing.Awake");
    }
Beispiel #2
0
    void Awake()
    {
        MojingLog.LogTrace("Enter Mojing.Awake");
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if  UNITY_EDITOR_OSX
#else
#if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_IOS
            MojingSDK.Unity_Init("Unity " + Application.unityVersion,
                                 "C3845343263589043", "4117870080735505", "751db2db58cb82308d9c455c6d236a10", "http://fuwu.mojing.cn/api/appdownload",
                                 Screen.width, Screen.height, 320, 320,
                                 GetProfilePath(), IntPtr.Zero);
#elif UNITY_ANDROID
            DisplayMetricsAndroid.InitDisplayMetricsAndroid();
            AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
            MojingSDK.Unity_Init("Unity " + Application.unityVersion,
                                 "C3845343263589043", "3908657356234505", "faadffa1383206111ae162969b340ad9", "www.mojing.cn",
                                 DisplayMetricsAndroid.WidthPixels, DisplayMetricsAndroid.HeightPixels, DisplayMetricsAndroid.XDPI, DisplayMetricsAndroid.YDPI,
                                 GetProfilePath(), activity.GetRawObject());
#endif
            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_SetGamePadAxisMode(0);

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            //CreateDummyCamera();
#if UNITY_IOS
            Application.targetFrameRate = 60;
#endif
            //StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");

            for (int i = 0; i < manufacturers_list.ManufacturerList.Count; i++)
            {
                product_list = MojingSDK.GetProducts(manufacturers_list.ManufacturerList[i].KEY, "zh");
                for (int j = 0; j < product_list.ProductList.Count; j++)
                {
                    glasses_list = MojingSDK.GetGlasses(product_list.ProductList[j].KEY, "zh");
                    for (int k = 0; k < glasses_list.GlassList.Count; k++)
                    {
                        string GlassName = manufacturers_list.ManufacturerList[i].Display + " " + product_list.ProductList[j].Display + " " + glasses_list.GlassList[k].Display;
                        string GlassKey  = glasses_list.GlassList[k].KEY;
                        string GlassID   = manufacturers_list.ManufacturerList[i].ID + "/" + product_list.ProductList[j].ID + "/" + glasses_list.GlassList[k].ID;
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                        glassesIDList.Add(GlassID);
                        glassesKey = FindGlassKey(manufacturers_list.ManufacturerList[i].ID, product_list.ProductList[j].ID, glasses_list.GlassList[k].ID);
                        //glassesKey = GlassKey;   //获取初始glassKey,mojingvrhead awake中用
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }

        MojingLog.LogTrace("Leave Mojing.Awake");
    }
Beispiel #3
0
    void Awake()
    {
        m_bResetTextureId = true;
        if (sdk == null)
        {
            MojingLog.LogWarn("Mojing SDK object is not sets.");
            sdk = this;
#if  UNITY_EDITOR_OSX
#else
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            MojingSDK.Unity_Init("C3845343263589043", "3956931912082870", "def5833993bbb001554ac192a79c9727", "www.mojing.cn", GetProfilePath());
#elif UNITY_IOS
            MojingSDK.Unity_Init("C3845343263589043", "3961565540023130", "f34c9b49192c5e6026f99125bdbabd27", "www.mojing.cn");
#endif
            MojingSDK.Unity_OnSurfaceChanged(Screen.width, Screen.height);
#endif
#if !UNITY_EDITOR && UNITY_IOS
            MojingSDK.Unity_SetGamePadAxisMode(0);

            /*
             * mode:   0 --- default value, Send Axis's direction (LEFT/RIGHT/UP/DOWN/CENTER)
             *      1 --- Send Axis's position (x,y,z)
             *      2 --- Send both Axis's direction and postion
             */
#endif
            MojingSDK.Unity_SetEngineVersion("Unity " + Application.unityVersion);
            //DontDestroyOnLoad(sdk);  //Remain Mojing GameObject even when change Scenes,just for Android
        }
        if (sdk != this)
        {
            MojingLog.LogWarn("Mojing SDK object should be a singleton.");
            bDuplicateMojing = true;
            enabled          = false;
            return;
        }

        try
        {
            //清除Glasses列表
            glassesNameList.Clear();
            glassesKeyList.Clear();

            CreateDummyCamera();
            Application.targetFrameRate = 60;
            //MojingRender.StereoScreen = null;

            //解析json文件中的glass列表,获取glassesKeyList
            manufacturers_list = MojingSDK.GetManufacturers("zh");
            foreach (ManufacturerInfo MI in manufacturers_list.ManufacturerList)
            {
                product_list = MojingSDK.GetProducts(MI.KEY, "zh");
                foreach (ProductInfo PI in product_list.ProductList)
                {
                    glasses_list = MojingSDK.GetGlasses(PI.KEY, "zh");
                    foreach (GlassInfo GI in glasses_list.GlassList)
                    {
                        string GlassName = MI.Display + " " + PI.Display + " " + GI.Display;
                        string GlassKey  = GI.KEY;
                        glassesKey = GlassKey; //获取初始glassKey,mojingvrhead awake中用
                        glassesKeyList.Add(GlassKey);
                        glassesNameList.Add(GlassName);
                    }
                }
            }
        }
        catch (Exception e)
        {
            MojingLog.LogError(e.ToString());
        }
        LCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Left").GetComponent <Camera>();
        RCamera = GameObject.Find("MojingMain/MojingVrHead/VR Camera Right").GetComponent <Camera>();
        MojingLog.LogTrace("Leave Mojing.Awake");
    }