Exemplo n.º 1
0
        /// <summary>
        /// Called when [UI loaded].
        /// </summary>
        /// <param name="objs">The objs.</param>
        private void OnceUILoaded(params object[] objs)
        {
            if (objs.Length == 0)
            {
                return;
            }

            if (!isUILoaded)
            {
                // FIX: This is called any time when the object is selected... So Gif will be loaded all the times that this object is reselected
                // Debug.Log("Loading gif UI (property drawer)!");

                // Fixed: If any exception occurs this will not continue executing
                isUILoaded = true;

                SerializedProperty property = objs[0] as SerializedProperty;
                string             path     = (string)objs[1];
                UniGif.GifFile     gif      = objs[2] as UniGif.GifFile;

                isFoldout = property.isExpanded;
                validPath = CheckValidGif(path);

                if (validPath)
                {
                    gif.UpdateFromPath(path, this);
                }
            }
        }
Exemplo n.º 2
0
 private void SetFirstFrame(UniGif.GifFile gif)
 {
     if (m_firstFrame == null)
     {
         m_firstFrame = gif.GetFirstFrame();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Draws the GIF.
        /// </summary>
        /// <param name="rect">The rect.</param>
        /// <param name="gif">The GIF.</param>
        public static bool DrawGIF(Rect rect, UniGif.GifFile gif)
        {
            if (gif == null)
            {
                throw new ArgumentNullException(nameof(gif), "Null gif!");
            }

            return(gif.Draw(rect));
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Draws a GIF.
        /// </summary>
        /// <param name="gif">The GIF.</param>
        public static void DrawGIF(UniGif.GifFile gif)
        {
            var texture = gif.GetFirstFrame();

            if (texture == null)
            {
                Debug.LogWarning("Null texture passed!");
                return;
            }

            var rect = GetRectForTexture(texture);

            rect = rect.ForceBoth(texture.width, texture.height);

            gif.Draw(rect);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when [UI loaded].
        /// </summary>
        /// <param name="objs">The objs.</param>
        private void OnceUILoaded(params object[] objs)
        {
            if (objs.Length == 0)
            {
                return;
            }

            if (!isUILoaded)
            {
                // FIX: This is called any time when the object is selected... So Gif will be loaded all the times that this object is reselected
                // Debug.Log("Loading gif UI (property drawer)!");

                // Fixed: If any exception occurs this will not continue executing
                isUILoaded = true;

                SerializedProperty property = objs[0] as SerializedProperty;
                string             path     = (string)objs[1];
                UniGif.GifFile     gif      = objs[2] as UniGif.GifFile;

                if (gif != null && gif.IsInitFlag == false)
                {
                    var mono = MonoUtils.FindExecutingInEditModeMonoBehaviour();
                    gif.Init(Path.GetFileNameWithoutExtension(path), mono, this);
                }

                isFoldout = property.isExpanded;
                validPath = CheckValidGif(path);

                if (validPath)
                {
                    if (gif == null)
                    {
                        Debug.LogException(new ArgumentNullException(nameof(gif), "Null gif passed!"));
                    }
                    gif?.UpdateFromPath(path, this);
                }
            }
        }