Пример #1
0
        internal string LoadRequest(int index, bool isBlocking, out StReadResult tResult)
        {
            string filename = Pictures[index];

            filename = GetCompleteFilePath(filename);
            if (LoadRequested == null)
            {
                LoadRequested = new bool[Pictures.Length];
            }

            PluginUtil.GetNativTextureInfo(filename, out tResult);
            //Debug.Log("tResult.readStatus " + tResult.readStatus + "Loading " + filename);
            if (tResult.readStatus == 0)
            {
                new BGJobPictureLoader(filename);
            }
            if (isBlocking)
            {
                while (tResult.readStatus != 2)
                {
                    PluginUtil.GetNativTextureInfo(filename, out tResult);
                }
            }
#if false //UNITY_EDITOR
            if (tResult.readStatus == 1)
            {
                Util.Log("Already requestd:" + filename);
            }
#endif
            return(filename);
        }
Пример #2
0
        public override void Execute()
        {
            StReadResult tResult = new StReadResult();

            int loaded = 0;

            for (int ii = 0; ii < m_param.m_collorArray.Length; ii++)
            {
                string fileName = m_param.m_asset.Pictures[ii];
                //m_collorArray[ii] = notYet;
                if (PluginUtil.GetNativTextureInfo(m_param.m_asset.GetCompleteFilePath(fileName), out tResult) != IntPtr.Zero)
                {
                    if (tResult.readStatus == 2)
                    {
                        m_param.m_collorArray[ii] = 0xffffffff;
                        loaded++;
                    }
                }
            }

            int length = m_param.m_collorArray.Length;

            if (loaded == length)
            {
                m_param.m_allLoaded = true;
            }
            else if (m_param.m_asset.m_loadingIndex == length)
            {
                // this is neccessary if script files are rebuilt while thread is execuiting in editor.
                m_param.m_asset.m_loadingIndex = -1;
#if UNITY_EDITOR
                //                Util.Log("Fetched the situation");
#endif
            }
        }
Пример #3
0
        private void ProcessInAdvanceLoading(double time, TimelineClip clip, int index)
        {
            var asset = clip.asset as MovieProxyPlayableAsset;
            int count = asset.Pictures.Length;


            if (m_nextInadvanceLoadingFrameArray[index] < count)
            {
                for (int check = 0; check < 4; check++)
                {
                    if (m_nextInadvanceLoadingFrameArray[index] >= 0 && m_nextInadvanceLoadingFrameArray[index] <= count)
                    {
                        if (!asset.IsLoadRequested(m_nextInadvanceLoadingFrameArray[index]))
                        {
                            StReadResult result = new StReadResult();
                            asset.LoadRequest(m_nextInadvanceLoadingFrameArray[index], false, out result);
                        }
                    }
                    m_nextInadvanceLoadingFrameArray[index]++;
                    if (m_nextInadvanceLoadingFrameArray[index] >= count)
                    {
                        break;
                    }
                }
            }
        }
Пример #4
0
        internal bool IsLoadRequested(int index)
        {
            string filename = Pictures[index];

            filename = GetCompleteFilePath(filename);
            StReadResult tResult = new StReadResult();

            PluginUtil.GetNativTextureInfo(filename, out tResult);
            return(tResult.readStatus != 0);
        }
Пример #5
0
        private void LoadStep(int step)
        {
            if (UpdateManager.IsPluginResetting())
            {
                return;
            }
            StReadResult tResult        = new StReadResult();
            int          loadRequestMax = m_loadingIndex + step;

            if (loadRequestMax > Pictures.Length)
            {
                loadRequestMax = Pictures.Length;
            }
            for (int ii = m_loadingIndex; ii <= loadRequestMax - 1; ii++)
            {
                if (ii == -1)
                {
                    continue;
                }

                LoadRequest(ii, false, out tResult);
            }
            m_loadingIndex = loadRequestMax;
        }
Пример #6
0
 public extern static IntPtr GetNativTextureInfo([MarshalAs(UnmanagedType.LPStr)] string fileName, out StReadResult tResult);
Пример #7
0
 public static IntPtr GetNativTextureInfo([MarshalAs(UnmanagedType.LPStr)] string fileName, out StReadResult tResult)
 {
     tResult.buffer     = IntPtr.Zero;
     tResult.width      = 0;
     tResult.height     = 0;
     tResult.readStatus = 0;
     return(IntPtr.Zero);
 }
Пример #8
0
        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);
        }