static private void FinalizeResetPlugin() { if (!IsPluginResetting()) { return; } CallResetDelegate(); double diff = EditorApplication.timeSinceStartup - s_PluginResetTime; if (diff > 0.016f * 60.0f) { PluginUtil.ResetOverwrapWindows(); PluginUtil.ResetAllLoadedTexture(); PluginUtil.DoneResetPlugin(); } }
public override void Execute() { StReadResult tResult; PluginUtil.GetNativTextureInfo(m_strFileName, out tResult); if (tResult.readStatus == 0) { //Debug.Log("Loading: " + m_strFileName); PluginUtil.LoadAndAlloc(m_strFileName); } #if UNITY_EDITOR if (tResult.readStatus == 1) { Util.Log("Already requestd:" + m_strFileName); } #endif m_sUpdated = true; }
internal bool SetTexture(GameObject go, int index, bool isBlocking, bool isAlreadySet) { var sID = go.GetInstanceID(); StReadResult tResult = new StReadResult(); string filename = LoadRequest(index, isBlocking, out tResult); if (!isAlreadySet && tResult.readStatus == 2) { Texture2D tex = null; #if UNITY_STANDALONE_OSX var textureFormat = TextureFormat.RGBA32; #elif UNITY_STANDALONE_WIN var textureFormat = TextureFormat.BGRA32; #endif tex = new Texture2D(tResult.width, tResult.height, textureFormat, false, false); tex.LoadRawTextureData(tResult.buffer, tResult.width * tResult.height * 4); tex.filterMode = FilterMode.Bilinear; tex.Apply(); var renderer = go.GetComponent <Renderer>(); Image image = null; SpriteRenderer spriteRenderer = null; IntPtr ptr = IntPtr.Zero; if ((spriteRenderer = go.GetComponent <SpriteRenderer>()) != null) { spriteRenderer.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f, 2, SpriteMeshType.FullRect); ptr = spriteRenderer.sprite.texture.GetNativeTexturePtr(); Assert.IsTrue(ptr != IntPtr.Zero); } else if (renderer != null) { var mat = go.GetComponent <Renderer>().sharedMaterial; mat.mainTexture = tex; // ptr = mat.mainTexture.GetNativeTexturePtr(); Assert.IsTrue(ptr != IntPtr.Zero); } else if ((image = go.GetComponent <Image>()) != null) { image.sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f, 1, SpriteMeshType.FullRect); ptr = image.mainTexture.GetNativeTexturePtr(); Assert.IsTrue(ptr != IntPtr.Zero); var material = image.material; #if UNITY_STANDALONE_WIN #if UNITY_2017_2_OR_NEWER #else if (material != null) { var id = Shader.PropertyToID("_GammaCorrection"); if (id > 0) { material.SetInt(id, 1); } } #endif #endif } PluginUtil.SetNativeTexturePtr(ptr, (uint)tResult.width, (uint)tResult.height, sID); isAlreadySet = true; } bool textureIsSet = false; if (tResult.readStatus == 2 && m_sLastIndex != index) { PluginUtil.SetLoadedTexture(filename, sID); textureIsSet = true; } if (textureIsSet && !UpdateManager.useCoroutine) { GL.IssuePluginEvent(PluginUtil.GetRenderEventFunc(), sID); } m_sLastIndex = index; return(isAlreadySet); }
static public bool IsPluginResetting() { return(PluginUtil.IsPluginResetting() != 0); }
static public void ResetPlugin() { PluginUtil.ResetPlugin(); s_PluginResetTime = EditorApplication.timeSinceStartup; }