void OnDisable() { MojingLog.LogTrace("Enter Mojing.OnDisable"); MojingLog.LogTrace("Leave Mojing.OnDisable"); }
private void OnApplicationPause(bool pause) { MojingLog.LogTrace("Mojing.OnApplicationPause"); SetPause(pause); }
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"); }
public void UpdateProfile() { MojingLog.LogTrace("Mojing.Lens.UpdateProfile"); FOV = MojingSDK.Unity_GetGlassesFOV(); separation = MojingSDK.Unity_GetGlassesSeparation(); }
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"); }
//private long frameCount = 0; IEnumerator EndOfFrame() { //frameCount = 0; MojingLog.LogTrace("Enter Mojing.EndOfFrame thread"); while (true) { yield return(new WaitForEndOfFrame()); if ((!bWaitForMojingWord) && VRModeEnabled && NeedDistortion) { LCamera.Render(); RCamera.Render(); if (MojingSDK.Unity_IsATW_ON() || m_bResetTextureId) { int iFrameIndex = 0; if (MojingSDK.Unity_IsATW_ON()) { iFrameIndex = MojingSDK.Unity_ATW_GetModelFrameIndex(); MojingLog.LogTrace("ATW: get iFrameIndex = " + iFrameIndex); } int tID = (int)MojingRender.StereoScreen[iFrameIndex * 2].GetNativeTexturePtr(); int sID = (int)MojingRender.StereoScreen[iFrameIndex * 2 + 1].GetNativeTexturePtr(); IntPtr tID_Metal = MojingRender.StereoScreen[iFrameIndex * 2].colorBuffer.GetNativeRenderBufferPtr(); IntPtr sID_Metal = MojingRender.StereoScreen[iFrameIndex * 2 + 1].colorBuffer.GetNativeRenderBufferPtr(); if (tID == 0 || sID == 0 || tID_Metal == IntPtr.Zero || sID_Metal == IntPtr.Zero) { // Skip a frame, the old texture id is invalid and no new texture id to use //MojingLog.LogTrace("Skip a frame since texture id is zero: " + tID + "," + sID); m_bResetTextureId = true; } else { if (_Last_left_TextureID != tID || _Last_right_TextureID != sID) { _Last_left_TextureID = tID; _Last_right_TextureID = sID; } if (_Last_left_TextureID_Metal != tID_Metal || _Last_right_TextureID_Metal != sID_Metal) { _Last_left_TextureID_Metal = tID_Metal; _Last_right_TextureID_Metal = sID_Metal; } //MojingLog.LogTrace("Set Texture ID: " + _Last_left_TextureID + "," + _Last_right_TextureID); #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_ANDROID if (MojingSDK.Unity_IsATW_ON() || MojingSDK.Unity_IsInterFBRPlatform()) { MojingSDK.ATW_SetTextureID(_Last_left_TextureID, _Last_right_TextureID, headView); } else { MojingSDK.SetTextureID(_Last_left_TextureID, _Last_right_TextureID); } #elif UNITY_IOS if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal) { MojingSDK.SetTextureID_Metal(tID_Metal, sID_Metal); } else { MojingSDK.SetTextureID(tID, sID); } #endif MojingSDK.Unity_DistortFrame(); if (!MojingSDK.Unity_IsATW_ON() && --m_ResetCount == 0) { m_bResetTextureId = false; } } } else { //MojingLog.LogTrace("Read Texture ID = " + tID + ", " + sID + " while set Texture ID: " + _Last_left_TextureID + "," + _Last_right_TextureID); #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_ANDROID if (MojingSDK.Unity_IsATW_ON() || MojingSDK.Unity_IsInterFBRPlatform()) { MojingSDK.ATW_SetTextureID(_Last_left_TextureID, _Last_right_TextureID, headView); } else { MojingSDK.SetTextureID(_Last_left_TextureID, _Last_right_TextureID); } #elif UNITY_IOS if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal) { MojingSDK.SetTextureID_Metal(_Last_left_TextureID_Metal, _Last_right_TextureID_Metal); } else { MojingSDK.SetTextureID(_Last_left_TextureID, _Last_right_TextureID); } #endif MojingSDK.Unity_DistortFrame(); } } } //MojingLog.LogTrace("Leave Mojing.EndOfFrame thread"); }
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"); }