コード例 #1
0
        void Update()
        {
            isDrawPhase = false;

            if (FlashResources.isPlatformReloadingEnabled)
            {
                FlashResources.reloadPendingResources();
            }

            if (_shaderDirty)
            {
                sceneBatch.shader = shader;
                debugBatch.shader = shader;

                _shaderDirty = false;
            }

            if (_resourceDirty)
            {
                UpdateContent();
                _resourceDirty = false;
            }

            isDrawPhase = true;

            debugBatch.Begin(GetGlobalMatrix());
            root.Draw();
            drawEvent.Dispatch();
            debugBatch.renderQueue = sceneBatch.renderQueue + 1;
            debugBatch.End();

            isDrawPhase = false;
        }
コード例 #2
0
        protected DisplayObject[] ConstructFromResource()
        {
            var count = _timeLine.instances.Length;

            var instances = new DisplayObject[count];

            for (int i = 0; i < count; i++)
            {
                var instName     = _timeLine.instances[i].name;
                var resourcePath = _timeLine.GetResourcePath(i);
                var resource     = FlashResources.GetResource <IDisplayResource>(resourcePath);

                DisplayObject instance;

                if (resource != null)
                {
                    instance = resource.CreateInstance();
                }
                else if (resourcePath == "flash/text/TextField")
                {
                    instance = new TextLabel()
                    {
                        text = ":-)"
                    };
                }
                else
                {
                    var className = resourcePath
                                    .Replace("Placeholders/", "")
                                    .Replace("/", ".");

                    var type = Type.GetType(className);
                    if (type != null)
                    {
                        instance = (DisplayObject)Activator.CreateInstance(type);
                    }
                    else
                    {
                        throw new Exception("Resource not found: " + resourcePath);
                    }
                }

                instance.name = instName;
                instances[i]  = instance;

                var field = GetType().GetField(instName);
                if (field != null && field.FieldType.IsInstanceOfType(instance))
                {
                    field.SetValue(this, instance);
                }
            }

            return(instances);
        }
コード例 #3
0
        private void Reload()
        {
            if (FlashResources.logLevel <= LogLevel.DEBUG)
            {
                Debug.LogWarning("Reloading...");
            }

            _descriptions = null;
            FlashResources.UnloadBundle(this);
            FlashResources.LoadBundle(this);
            AddBundleWatcher();
        }
コード例 #4
0
        void UpdateContent()
        {
            root.RemoveChildren();

            if (resourcePath.IsNullOrEmpty())
            {
                return;
            }

            var bundleName = resourcePath.Split("/")[0];
            var bundle     = FlashResources.GetBundleInstance(bundleName);

            if (bundle == null)
            {
                Debug.Log("Bundle not found: " + bundleName);
                return;
            }

            if (!bundle.isLoaded)
            {
                FlashResources.LoadBundle(bundle);
            }

            var resource = FlashResources.GetResource <IDisplayResource>(resourcePath);

            if (resource == null)
            {
                Debug.Log("Resource not found: " + resourcePath);
                return;
            }

            var instance = resource.CreateInstance();

            root.AddChild(instance);

            if (isPlaying)
            {
                if (instance.totalFrames > 1)
                {
                    instance.Play();
                }
                else
                {
                    var displayContainer = instance as DisplayContainer;
                    if (displayContainer != null)
                    {
                        displayContainer.PlayAllChildren();
                    }
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// Calls FlashResources.UnloadBundle(this);
 /// </summary>
 public void Unload()
 {
     FlashResources.UnloadBundle(this);
 }
コード例 #6
0
 /// <summary>
 /// Calls FlashResources.LoadBundle(this);
 /// </summary>
 public void Load()
 {
     FlashResources.LoadBundle(this);
 }