Пример #1
0
        public virtual void Restore(IRestoreData restoreData)
        {
            var data = restoreData as CompositeSpriteControllerBaseRestoreData;

            data.transformRestoreData.Restore(transform);
            color = data.color;
            RenderQueueOverrider.Ensure(gameObject).renderQueue = data.renderQueue;
            SetPose(data.currentImageName, false);
        }
        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);
            }
        }
        public virtual IRestoreData GetRestoreData()
        {
            // Material must be RestorableMaterial or DefaultMaterial
            MaterialRestoreData materialRestoreData;

            if (spriteRenderer != null && spriteRenderer.sharedMaterial is RestorableMaterial)
            {
                materialRestoreData = RestorableMaterial.GetRestoreData(spriteRenderer.sharedMaterial);
            }
            else
            {
                materialRestoreData = null;
            }

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

            return(new CompositeSpriteControllerBaseRestoreData(currentImageName, transform, color, materialRestoreData,
                                                                renderQueue));
        }
Пример #4
0
        public virtual IRestoreData GetRestoreData()
        {
            int renderQueue = RenderQueueOverrider.Ensure(gameObject).renderQueue;

            return(new CompositeSpriteControllerBaseRestoreData(currentImageName, transform, color, renderQueue));
        }