Example #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;

                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);
                }
            }
        }