Esempio n. 1
0
        private static void ProcessMovieProxyTrack(MovieProxyTrack track)
        {
            foreach (var clip in track.GetClips())
            {
                // You might want to use "as" rather than compare type.
                // "as" sometimes fail on first importing time for project.
                if (clip.asset.GetType() != typeof(MovieProxyPlayableAsset))
                {
                    Debug.LogError("MovieProxyPlayableAsset is broken:" + clip.asset.name);
                    continue;
                }

                /*
                 * if (clip.asset == null)
                 * {
                 *  Debug.LogError("MovieProxyPlayableAsset on " + clip.displayName + " is broken.");
                 *  continue;
                 * }*/

                MovieProxyPlayableAsset asset = (MovieProxyPlayableAsset)clip.asset;
                int length = asset.Pictures.Length;
                if (m_MovieProxyPlayableAssetToColorArray.ContainsKey(asset))
                {
                }
                else
                {
                    m_MovieProxyPlayableAssetToColorArray.Add(asset, new BGJobCacheParam(asset));
                }
                var param        = m_MovieProxyPlayableAssetToColorArray[asset];
                int allAreLoaded = PluginUtil.GetAllAreLoaded(asset.GetInstanceID());

                if (allAreLoaded == 0)
                {
                    new BGJobCacheChecker(m_MovieProxyPlayableAssetToColorArray[asset]);
                    UInt32[] colorArray = m_MovieProxyPlayableAssetToColorArray[asset].m_collorArray;
                    if (colorArray == null)
                    {
                        return;
                    }
                    PluginUtil.SetOverwrapWindowData(asset.GetInstanceID(), colorArray, colorArray.Length);
                    if (param.m_allLoaded)
                    {
                        PluginUtil.SetAllAreLoaded(asset.GetInstanceID(), 1);
                    }
                }
                else
                {
                    PluginUtil.HideOverwrapWindow(asset.GetInstanceID());
                }
            }
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        private static void ShowOverwrapWindows()
        {
            var  timeLineWindow = UpdateManager.GetTimelineWindow();
            Rect windowPos      = ((EditorWindow)timeLineWindow).position;
            //       Rect windowPos = GetWindowPosition(timeLineWindow);


            // Get Treeview
            var bf       = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField;
            var type     = timeLineWindow.GetType();
            var info     = type.GetProperty("treeView", bf);
            var treeview = info.GetValue(timeLineWindow, null);

            // Get tracksBounds
            info = type.GetProperty("tracksBounds", bf);
            Rect trackbounds = (Rect)info.GetValue(timeLineWindow, null);

            if (treeview == null)
            {
                return;
            }


            // Get ScrollPosition
            type = treeview.GetType();
            info = type.GetProperty("scrollPosition", bf);
            Vector2 treeviewPos = (Vector2)info.GetValue(treeview, null);



            // Get Tree view
            type = treeview.GetType();
            info = type.GetProperty("allClipGuis", bf);
            var         allClipGui = info.GetValue(treeview, null);
            IEnumerable en         = allClipGui as IEnumerable;

            //        Util.Log("treeviewPos.y:: " + treeviewPos.y);
            //        Util.Log("trackbounds.y:: " + trackbounds.y);
            //        Util.Log("window.Pos.y:: " + windowPos.y);
            //        Util.Log("window.Pos.x:: " + windowPos.x);
            float offsetY = 24.0f;

            foreach (var obj in en)
            {
                type = obj.GetType();
                info = type.GetProperty("boundingRect", bf);
                Rect rect = (Rect)info.GetValue(obj, null);

                info = type.GetProperty("clip", bf);
                var clip      = info.GetValue(obj, null) as UnityEngine.Timeline.TimelineClip;
                var assetType = clip.asset.GetType();
                if (assetType != typeof(MovieProxyPlayableAsset))
                {
                    continue;
                }
                float startX      = windowPos.x + rect.x;
                float startY      = trackbounds.y + windowPos.y + rect.y - treeviewPos.y + offsetY;
                float width       = rect.width;
                int   forceChange = 0;
                if (startX <= trackbounds.x + windowPos.x)
                {
                    var orgStartX = startX;
                    startX = trackbounds.x + windowPos.x;
                    width -= startX - orgStartX;
                }

                if (startX + width > windowPos.x + windowPos.width)
                {
                    width -= startX + width - (windowPos.x + windowPos.width);
                }
                int isLoaded = PluginUtil.GetAllAreLoaded(clip.asset.GetInstanceID());

                if ((rect.y - treeviewPos.y > 0.0f - offsetY && rect.y - treeviewPos.y < trackbounds.height - trackbounds.y && width > 0.0f - offsetY) &&
                    isLoaded == 0)
                {
                    PluginUtil.ShowOverwrapWindow(clip.asset.GetInstanceID(), (int)startX, (int)startY, (int)width, 1, forceChange);    // (int)rect.height);
                }
                else
                {
                    PluginUtil.HideOverwrapWindow(clip.asset.GetInstanceID());
                }
            }
        }
Esempio n. 6
0
 static public bool IsPluginResetting()
 {
     return(PluginUtil.IsPluginResetting() != 0);
 }
Esempio n. 7
0
 static public void ResetPlugin()
 {
     PluginUtil.ResetPlugin();
     s_PluginResetTime = EditorApplication.timeSinceStartup;
 }