Example #1
0
        public void Restore(IRestoreData restoreData)
        {
            var data = restoreData as PostProcessingRestoreData;

            // Materials must be RestorableMaterial
            MaterialFactory factory = MaterialPool.Ensure(gameObject).factory;

            layers.Clear();
            foreach (var materialRestoreData in data.layersData)
            {
                var material = RestorableMaterial.RestoreMaterialFromData(materialRestoreData, factory);
                layers.Add(material);
            }
        }
        public virtual void Restore(IRestoreData restoreData)
        {
            var data = restoreData as CompositeSpriteControllerBaseRestoreData;

            data.transformRestoreData.Restore(transform);
            color = data.color;

            if (spriteRenderer != null)
            {
                // Material must be RestorableMaterial or DefaultMaterial
                if (data.materialRestoreData != null)
                {
                    MaterialFactory factory = MaterialPoolComponent.Ensure(gameObject).factory;
                    spriteRenderer.material =
                        RestorableMaterial.RestoreMaterialFromData(data.materialRestoreData, factory);
                }
                else
                {
                    spriteRenderer.material = MaterialPoolComponent.Ensure(gameObject).defaultMaterial;
                }
            }

            RenderQueueOverrider.Ensure(gameObject).renderQueue = data.renderQueue;

            if (data.currentImageName == currentImageName)
            {
                return;
            }

            if (!string.IsNullOrEmpty(data.currentImageName))
            {
                string[] parts = StringToPoseArray(data.currentImageName);
                if (parts.Length == 1)
                {
                    SetImage(data.currentImageName, fade: false);
                }
                else
                {
                    SetPose(parts, fade: false);
                }
            }
            else
            {
                ClearImage(fade: false);
            }
        }
Example #3
0
        public void Restore(IRestoreData restoreData)
        {
            var data = restoreData as PostProcessingRestoreData;

            // Materials must be RestorableMaterial
            MaterialFactory factory = MaterialPoolComponent.Ensure(gameObject).factory;

            layers.Clear();
            foreach (var layerData in data.layersData)
            {
                var layer = new List <Material>();
                foreach (var materialRestoreData in layerData)
                {
                    var material = RestorableMaterial.RestoreMaterialFromData(materialRestoreData, factory);
                    layer.Add(material);
                }

                layers.Add(layer);
            }

            layersEnabledUntil = data.layersEnabledUntil;
        }