/**
         * <summary>Serialises appropriate GameObject values into a string.</summary>
         * <returns>The data, serialised as a string</returns>
         */
        public override string SaveData()
        {
            VisibilityData visibilityData = new VisibilityData();

            visibilityData.objectID      = constantID;
            visibilityData.savePrevented = savePrevented;

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                visibilityData.isFading = spriteFader.isFading;
                if (spriteFader.isFading)
                {
                    if (spriteFader.fadeType == FadeType.fadeIn)
                    {
                        visibilityData.isFadingIn = true;
                    }
                    else
                    {
                        visibilityData.isFadingIn = false;
                    }

                    visibilityData.fadeTime      = spriteFader.fadeTime;
                    visibilityData.fadeStartTime = spriteFader.fadeStartTime;
                }
                visibilityData.fadeAlpha = GetComponent <SpriteRenderer>().color.a;
            }
            else if (GetComponent <SpriteRenderer>() && saveColour)
            {
                Color _color = GetComponent <SpriteRenderer>().color;
                visibilityData.colourR = _color.r;
                visibilityData.colourG = _color.g;
                visibilityData.colourB = _color.b;
                visibilityData.colourA = _color.a;
            }

            if (GetComponent <FollowTintMap>())
            {
                visibilityData = GetComponent <FollowTintMap>().SaveData(visibilityData);
            }

            if (limitVisibility)
            {
                visibilityData.isOn = !limitVisibility.isLockedOff;
            }
            else if (GetComponent <Renderer>())
            {
                visibilityData.isOn = GetComponent <Renderer>().enabled;
            }
            else if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    visibilityData.isOn = _renderer.enabled;
                    break;
                }
            }

            return(Serializer.SaveScriptData <VisibilityData> (visibilityData));
        }
Пример #2
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }
            else if (GetComponent <SpriteRenderer>() && saveColour)
            {
                Color _color = new Color(data.colourR, data.colourG, data.colourB, data.colourA);
                GetComponent <SpriteRenderer>().color = _color;
            }

            if (GetComponent <FollowTintMap>())
            {
                GetComponent <FollowTintMap>().LoadData(data);
            }

            if (limitVisibility)
            {
                limitVisibility.isLockedOff = !data.isOn;
            }
            else if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().enabled = data.isOn;
            }

            if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    _renderer.enabled = data.isOn;
                }
            }

            loadedData = true;
        }
        /**
         * <summary>Updates its own variables from a VisibilityData class.</summary>
         * <param name = "data">The VisibilityData class to load from</param>
         */
        public void LoadData(VisibilityData data)
        {
            useDefaultTintMap = data.useDefaultTintMap;
            SetIntensity(data.tintIntensity, 0f);

            if (!useDefaultTintMap && data.tintMapID != 0)
            {
                tintMap = Serializer.returnComponent <TintMap> (data.tintMapID);
            }

            ResetTintMap();
        }
Пример #4
0
        /**
         * <summary>Updates it's own variables from a VisibilityData class.</summary>
         * <param name = "data">The VisibilityData class to load from</param>
         */
        public void LoadData(VisibilityData data)
        {
            useDefaultTintMap = data.useDefaultTintMap;
            SetIntensity (data.tintIntensity, 0f);

            if (!useDefaultTintMap && data.tintMapID != 0)
            {
                tintMap = Serializer.returnComponent <TintMap> (data.tintMapID);
            }

            ResetTintMap ();
        }
Пример #5
0
        /**
         * <summary>Updates its own variables from a VisibilityData class.</summary>
         * <param name = "data">The VisibilityData class to load from</param>
         */
        public void LoadData(VisibilityData data)
        {
            useDefaultTintMap = data.useDefaultTintMap;
            SetIntensity(data.tintIntensity, 0f);

            if (!useDefaultTintMap && data.tintMapID != 0)
            {
                tintMap = ConstantID.GetComponent <TintMap> (data.tintMapID);
            }

            ResetTintMap();
        }
        /**
         * <summary>Updates a VisibilityData class with its own variables that need saving.</summary>
         * <param name = "visibilityData">The original VisibilityData class</param>
         * <returns>The updated VisibilityData class</returns>
         */
        public VisibilityData SaveData(VisibilityData visibilityData)
        {
            visibilityData.useDefaultTintMap = useDefaultTintMap;
            visibilityData.tintIntensity     = targetIntensity;

            visibilityData.tintMapID = 0;
            if (!useDefaultTintMap && tintMap != null && tintMap.gameObject != null)
            {
                visibilityData.tintMapID = Serializer.GetConstantID(tintMap.gameObject);
            }

            return(visibilityData);
        }
		public void LoadData (VisibilityData data)
		{
			if (GetComponent<Renderer>())
			{
				GetComponent<Renderer>().enabled = data.isOn;
			}

			if (affectChildren)
			{
				foreach (Transform child in transform)
				{
					if (child.gameObject.GetComponent<Renderer>())
					{
						child.gameObject.GetComponent<Renderer>().enabled = data.isOn;
					}
				}
			}
		}
Пример #8
0
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                return;
            }

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }

            if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().enabled = data.isOn;
            }

            if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    _renderer.enabled = data.isOn;
                }
            }
        }
Пример #9
0
        public override string SaveData()
        {
            VisibilityData visibilityData = new VisibilityData();

            visibilityData.objectID = constantID;

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                visibilityData.isFading = spriteFader.isFading;
                if (spriteFader.isFading)
                {
                    if (spriteFader.fadeType == FadeType.fadeIn)
                    {
                        visibilityData.isFadingIn = true;
                    }
                    else
                    {
                        visibilityData.isFadingIn = false;
                    }

                    visibilityData.fadeTime      = spriteFader.fadeTime;
                    visibilityData.fadeStartTime = spriteFader.fadeStartTime;
                }
                visibilityData.fadeAlpha = GetComponent <SpriteRenderer>().color.a;
            }

            if (GetComponent <Renderer>())
            {
                visibilityData.isOn = GetComponent <Renderer>().enabled;
            }
            else if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    visibilityData.isOn = _renderer.enabled;
                    break;
                }
            }

            return(Serializer.SaveScriptData <VisibilityData> (visibilityData));
        }
		public VisibilityData SaveData ()
		{
			VisibilityData visibilityData = new VisibilityData ();
			visibilityData.objectID = constantID;
			
			if (GetComponent<Renderer>())
			{
				visibilityData.isOn = GetComponent<Renderer>().enabled;
			}
			else if (affectChildren)
			{
				foreach (Transform child in transform)
				{
					if (child.gameObject.GetComponent<Renderer>())
					{
						visibilityData.isOn = child.gameObject.GetComponent<Renderer>().enabled;
						break;
					}
				}
			}
			
			return (visibilityData);
		}
Пример #11
0
        public override string SaveData()
        {
            VisibilityData visibilityData = new VisibilityData ();
            visibilityData.objectID = constantID;

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                visibilityData.isFading = spriteFader.isFading;
                if (spriteFader.isFading)
                {
                    if (spriteFader.fadeType == FadeType.fadeIn)
                    {
                        visibilityData.isFadingIn = true;
                    }
                    else
                    {
                        visibilityData.isFadingIn = false;
                    }

                    visibilityData.fadeTime = spriteFader.fadeTime;
                    visibilityData.fadeStartTime = spriteFader.fadeStartTime;
                }
                visibilityData.fadeAlpha = GetComponent <SpriteRenderer>().color.a;
            }

            if (GetComponent <Renderer>())
            {
                visibilityData.isOn = GetComponent <Renderer>().enabled;
            }
            else if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    visibilityData.isOn = _renderer.enabled;
                    break;
                }
            }

            return Serializer.SaveScriptData <VisibilityData> (visibilityData);
        }
Пример #12
0
        /**
         * <summary>Updates a VisibilityData class with it's own variables that need saving.</summary>
         * <param name = "visibilityData">The original VisibilityData class</param>
         * <returns>The updated VisibilityData class</returns>
         */
        public VisibilityData SaveData(VisibilityData visibilityData)
        {
            visibilityData.useDefaultTintMap = useDefaultTintMap;
            visibilityData.tintIntensity = targetIntensity;

            visibilityData.tintMapID = 0;
            if (!useDefaultTintMap && tintMap != null && tintMap.gameObject != null)
            {
                visibilityData.tintMapID = Serializer.GetConstantID (tintMap.gameObject);
            }

            return visibilityData;
        }
Пример #13
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            SpriteFader spriteFader = GetComponent <SpriteFader>();

            if (spriteFader)
            {
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }
            else
            {
                if (saveColour)
                {
                    SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
                    if (spriteRenderer)
                    {
                        Color _color = new Color(data.colourR, data.colourG, data.colourB, data.colourA);
                        spriteRenderer.color = _color;
                    }
                }
            }

            FollowTintMap followTintMap = GetComponent <FollowTintMap>();

            if (followTintMap)
            {
                followTintMap.LoadData(data);
            }

            if (limitVisibility)
            {
                limitVisibility.isLockedOff = !data.isOn;
            }
            else
            {
                Renderer renderer = GetComponent <Renderer>();
                if (renderer)
                {
                    renderer.enabled = data.isOn;
                }
                else
                {
                    Canvas canvas = GetComponent <Canvas>();
                    if (canvas)
                    {
                        canvas.enabled = data.isOn;
                    }
                }
            }

            if (affectChildren)
            {
                Renderer[] renderers = GetComponentsInChildren <Renderer>();
                foreach (Renderer _renderer in renderers)
                {
                    _renderer.enabled = data.isOn;
                }
            }

            loadedData = true;
        }