Inheritance: Shadow
 static public int ModifyMesh(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, "ModifyMesh__VertexHelper", argc, 2, typeof(UnityEngine.UI.VertexHelper)))
         {
             UnityEngine.UI.Outline      self = (UnityEngine.UI.Outline)checkSelf(l);
             UnityEngine.UI.VertexHelper a1;
             checkType(l, 3, out a1);
             self.ModifyMesh(a1);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, "ModifyMesh__Mesh", argc, 2, typeof(UnityEngine.Mesh)))
         {
             UnityEngine.UI.Outline self = (UnityEngine.UI.Outline)checkSelf(l);
             UnityEngine.Mesh       a1;
             checkType(l, 3, out a1);
             self.ModifyMesh(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static int ModifyMesh(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.UI.Outline), typeof(UnityEngine.Mesh)))
            {
                UnityEngine.UI.Outline obj  = (UnityEngine.UI.Outline)ToLua.ToObject(L, 1);
                UnityEngine.Mesh       arg0 = (UnityEngine.Mesh)ToLua.ToObject(L, 2);
                obj.ModifyMesh(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.UI.Outline), typeof(UnityEngine.UI.VertexHelper)))
            {
                UnityEngine.UI.Outline      obj  = (UnityEngine.UI.Outline)ToLua.ToObject(L, 1);
                UnityEngine.UI.VertexHelper arg0 = (UnityEngine.UI.VertexHelper)ToLua.ToObject(L, 2);
                obj.ModifyMesh(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.UI.Outline.ModifyMesh"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static int QPYX_ModifyMesh_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <UnityEngine.Mesh>(L_YXQP, 2))
         {
             UnityEngine.UI.Outline QPYX_obj_YXQP  = (UnityEngine.UI.Outline)ToLua.CheckObject <UnityEngine.UI.Outline>(L_YXQP, 1);
             UnityEngine.Mesh       QPYX_arg0_YXQP = (UnityEngine.Mesh)ToLua.ToObject(L_YXQP, 2);
             QPYX_obj_YXQP.ModifyMesh(QPYX_arg0_YXQP);
             return(0);
         }
         else if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <UnityEngine.UI.VertexHelper>(L_YXQP, 2))
         {
             UnityEngine.UI.Outline      QPYX_obj_YXQP  = (UnityEngine.UI.Outline)ToLua.CheckObject <UnityEngine.UI.Outline>(L_YXQP, 1);
             UnityEngine.UI.VertexHelper QPYX_arg0_YXQP = (UnityEngine.UI.VertexHelper)ToLua.ToObject(L_YXQP, 2);
             QPYX_obj_YXQP.ModifyMesh(QPYX_arg0_YXQP);
             return(0);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.UI.Outline.ModifyMesh"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Exemplo n.º 4
0
        /// <summary>Tweens a Outline's effectDistance to the given value.
        /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
        public static TweenerCore <Vector2, Vector2, VectorOptions> DOScale(this Outline target, Vector2 endValue, float duration)
        {
            TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration);

            t.SetTarget(target);
            return(t);
        }
Exemplo n.º 5
0
        /// <summary>Tweens a Outline's effectColor alpha to the given value.
        /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
        /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
        public static TweenerCore <Color, Color, ColorOptions> DOFade(this Outline target, float endValue, float duration)
        {
            TweenerCore <Color, Color, ColorOptions> t = DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration);

            t.SetTarget(target);
            return(t);
        }
 static public int ModifyMesh(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.UI.Outline      self = (UnityEngine.UI.Outline)checkSelf(l);
         UnityEngine.UI.VertexHelper a1;
         checkType(l, 2, out a1);
         self.ModifyMesh(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Exemplo n.º 7
0
    static int DOFade(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(UnityEngine.UI.Outline), typeof(float), typeof(float)))
        {
            UnityEngine.UI.Outline arg0 = (UnityEngine.UI.Outline)LuaScriptMgr.GetLuaObject(L, 1);
            float arg1            = (float)LuaDLL.lua_tonumber(L, 2);
            float arg2            = (float)LuaDLL.lua_tonumber(L, 3);
            DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOFade(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(UnityEngine.UI.Text), typeof(float), typeof(float)))
        {
            UnityEngine.UI.Text arg0 = (UnityEngine.UI.Text)LuaScriptMgr.GetLuaObject(L, 1);
            float arg1            = (float)LuaDLL.lua_tonumber(L, 2);
            float arg2            = (float)LuaDLL.lua_tonumber(L, 3);
            DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOFade(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(UnityEngine.UI.Image), typeof(float), typeof(float)))
        {
            UnityEngine.UI.Image arg0 = (UnityEngine.UI.Image)LuaScriptMgr.GetLuaObject(L, 1);
            float arg1            = (float)LuaDLL.lua_tonumber(L, 2);
            float arg2            = (float)LuaDLL.lua_tonumber(L, 3);
            DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOFade(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(CanvasGroup), typeof(float), typeof(float)))
        {
            CanvasGroup         arg0 = (CanvasGroup)LuaScriptMgr.GetLuaObject(L, 1);
            float               arg1 = (float)LuaDLL.lua_tonumber(L, 2);
            float               arg2 = (float)LuaDLL.lua_tonumber(L, 3);
            DG.Tweening.Tweener o    = DG.Tweening.ShortcutExtensions46.DOFade(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(UnityEngine.UI.Graphic), typeof(float), typeof(float)))
        {
            UnityEngine.UI.Graphic arg0 = (UnityEngine.UI.Graphic)LuaScriptMgr.GetLuaObject(L, 1);
            float arg1            = (float)LuaDLL.lua_tonumber(L, 2);
            float arg2            = (float)LuaDLL.lua_tonumber(L, 3);
            DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOFade(arg0, arg1, arg2);
            LuaScriptMgr.PushObject(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: DG.Tweening.ShortcutExtensions46.DOFade");
        }

        return(0);
    }
Exemplo n.º 8
0
 public override void Apply(object value, string[] args)
 {
     if (value == null)
     {
         return;
     }
     UnityEngine.UI.Outline outline =
         (UnityEngine.UI.Outline)value;
     outline.effectColor = MDUtils.ParseColor(args[0]);
 }
Exemplo n.º 9
0
    static int DOScale(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        UnityEngine.UI.Outline arg0 = (UnityEngine.UI.Outline)LuaScriptMgr.GetUnityObject(L, 1, typeof(UnityEngine.UI.Outline));
        Vector2 arg1 = LuaScriptMgr.GetVector2(L, 2);
        float   arg2 = (float)LuaScriptMgr.GetNumber(L, 3);

        DG.Tweening.Tweener o = DG.Tweening.ShortcutExtensions46.DOScale(arg0, arg1, arg2);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Exemplo n.º 10
0
		public override void OnEnter ()
		{
			component = gameObject.Value.GetComponent<Outline>();
			if (component == null) {
				component = gameObject.Value.AddComponent<Outline>();
			}
			DoSetOutline();
			if (!everyFrame) {
				Finish ();
			}
		}
Exemplo n.º 11
0
    public static void SetStyle(CText text, int styleIdx = 0)
    {
        //if (text.colorIdx >= colors.Length)
        //    text.colorIdx = colors.Length - 1;
        //string[] styleStr = colors[text.colorIdx].Split(';');
        //text.color = GetColor(styleStr[0]);

        //if (!text.shadowEff)
        //    text.shadowEff = text.gameObject.AddComponent<UnityEngine.UI.Shadow>();
        //if (!text.outlineEff)
        //    text.outlineEff = text.gameObject.AddComponent<Outline>();

        //text.shadowEff.enabled = false;
        //text.outlineEff.enabled = false;

        //if (styleStr.Length > 1)
        //{
        //    for (int i = 1; i < styleStr.Length; i++)
        //    {
        //        string[] osStr = styleStr[i].Split(':');
        //        if (osStr[0] == "s")
        //        {
        //            text.shadowEff.enabled = true;
        //            text.shadowEff.effectColor = GetColor(osStr[1]);
        //        }
        //        else if (osStr[0] == "o")
        //        {
        //            text.outlineEff.enabled = true;
        //            text.outlineEff.effectColor = GetColor(osStr[1]);
        //        }
        //    }
        //}
        if (!text)
        {
            return;
        }
        UnityEngine.UI.Shadow[] shadows = text.GetComponentsInChildren <UnityEngine.UI.Shadow>();
        for (int i = 0; i < shadows.Length; i++)
        {
            DestroyImmediate(shadows[i]);
        }

        if (styleIdx == 1)
        {
            UnityEngine.UI.Shadow sd = text.gameObject.AddComponent <UnityEngine.UI.Shadow>();
            sd.effectColor = GetColor(sdColor);
        }
        else if (styleIdx == 2)
        {
            UnityEngine.UI.Outline ol = text.gameObject.AddComponent <UnityEngine.UI.Outline>();
            ol.effectColor = GetColor(olColor);
        }
    }
 static public int ModifyMesh(IntPtr l)
 {
     try {
         UnityEngine.UI.Outline      self = (UnityEngine.UI.Outline)checkSelf(l);
         UnityEngine.UI.VertexHelper a1;
         checkType(l, 2, out a1);
         self.ModifyMesh(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 13
0
 static public int ModifyVertices(IntPtr l)
 {
     try{
         UnityEngine.UI.Outline self = (UnityEngine.UI.Outline)checkSelf(l);
         System.Collections.Generic.List <UnityEngine.UIVertex> a1;
         checkType(l, 2, out a1);
         self.ModifyVertices(a1);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemplo n.º 14
0
 static public int ModifyMesh__Mesh(IntPtr l)
 {
     try {
         UnityEngine.UI.Outline self = (UnityEngine.UI.Outline)checkSelf(l);
         UnityEngine.Mesh       a1;
         checkType(l, 2, out a1);
         self.ModifyMesh(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 15
0
 static public int ModifyVertices(IntPtr l)
 {
     try {
         UnityEngine.UI.Outline self = (UnityEngine.UI.Outline)checkSelf(l);
         System.Collections.Generic.List <UnityEngine.UIVertex> a1;
         checkType(l, 2, out a1);
         self.ModifyVertices(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        // Cache the sprite component
        SpriteComponent  = GetComponentInParent <SpriteRenderer>();
        TextComponent    = GetComponentInParent <UnityEngine.UI.Text>();
        OutlineComponent = GetComponentInParent <UnityEngine.UI.Outline>();

        // Modifier mode
        ModifierMode = ColorMode.TIME_BASED;

        // Random start value
        CurrentAngle = Random.Range(0, 360);

        // Cache the game controller component
        GameControllerRef = GameObject.Find("GameController").GetComponent <GameController>();
    }
Exemplo n.º 17
0
	static int DOColor(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 3);
			UnityEngine.UI.Outline obj = (UnityEngine.UI.Outline)ToLua.CheckObject<UnityEngine.UI.Outline>(L, 1);
			UnityEngine.Color arg0 = ToLua.ToColor(L, 2);
			float arg1 = (float)LuaDLL.luaL_checknumber(L, 3);
			DG.Tweening.Core.TweenerCore<UnityEngine.Color,UnityEngine.Color,DG.Tweening.Plugins.Options.ColorOptions> o = obj.DOColor(arg0, arg1);
			ToLua.PushObject(L, o);
			return 1;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
    /// <summary>
    /// Initialises the script
    /// </summary>
    void Start()
    {
        sm_islandsOwned.Clear();

        m_scoreOutline   = scoreText.GetComponent <UnityEngine.UI.Outline>();
        m_scoreTransform = scoreText.GetComponent <RectTransform>();
        scoreText.gameObject.SetActive(false);

        m_nodes = transform.parent.GetComponentsInChildren <IslandDiscoveryNode>();
        foreach (var node in m_nodes)
        {
            node.SetTrigger(this);
        }

        var islands = transform.parent.GetComponentsInChildren <SpriteRenderer>();

        foreach (var island in islands)
        {
            if (island.CompareTag("Island"))
            {
                m_islands.Add(island);
            }
        }

        if (m_islands.Count == 0)
        {
            Debug.LogError("No associated island sprite");
        }
        if (m_nodes.Length == 0)
        {
            Debug.LogError("No associated nodes");
        }

        m_canvas         = GetComponent <Canvas>();
        m_canvas.enabled = false;
    }
Exemplo n.º 19
0
 void Awake()
 {
     Outline = GetComponent <UnityEngine.UI.Outline>();
     Icon    = GetComponent <Image>();
     Unhighlight();
 }
Exemplo n.º 20
0
 /// <summary>Tweens a Outline's effectDistance to the given value.
 /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOScale(this  UnityEngine.UI.Outline target, Vector2 endValue, float duration)
 {
     return(DOTween.To(() => target.effectDistance, x => target.effectDistance = x, endValue, duration)
            .SetTarget(target));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a option.
        /// </summary>
        /// <param name="index">Index.</param>
        protected void CreateOption(int index, ToggleGroup toggleGroup)
        {
            if (this.m_ListObject == null)
            {
                return;
            }

            // Create the option game object with it's components
            GameObject optionObject = new GameObject("Option " + index.ToString(), typeof(RectTransform));

            // Change parents
            optionObject.transform.SetParent(this.m_ListObject.transform, false);

            // Get the option component
            UISelectField_Option optionComp = optionObject.AddComponent <UISelectField_Option>();

            // Prepare the option background
            if (this.optionBackgroundSprite != null)
            {
                Image image = optionObject.AddComponent <Image>();
                image.sprite = this.optionBackgroundSprite;
                image.type   = this.optionBackgroundSpriteType;
                image.color  = this.optionBackgroundSpriteColor;

                // Add the graphic as the option transition target
                optionComp.targetGraphic = image;
            }

            // Prepare the option for animation
            if (this.optionBackgroundTransitionType == Transition.Animation)
            {
                // Attach animator component
                Animator animator = optionObject.AddComponent <Animator>();

                // Set the animator controller
                animator.runtimeAnimatorController = this.optionBackgroundAnimatorController;
            }

            // Apply the option padding
            VerticalLayoutGroup vlg = optionObject.AddComponent <VerticalLayoutGroup>();

            vlg.padding = this.optionPadding;

            // Create the option text
            GameObject textObject = new GameObject("Label", typeof(RectTransform));

            // Change parents
            textObject.transform.SetParent(optionObject.transform, false);

            // Apply pivot
            (textObject.transform as RectTransform).pivot = new Vector2(0f, 1f);

            // Prepare the text
            Text text = textObject.AddComponent <Text>();

            text.font      = this.optionFont;
            text.fontSize  = this.optionFontSize;
            text.fontStyle = this.optionFontStyle;
            text.color     = this.optionColor;

            if (this.options != null)
            {
                text.text = this.options[index];
            }

            // Apply normal state transition color
            if (this.optionTextTransitionType == OptionTextTransitionType.CrossFade)
            {
                text.canvasRenderer.SetColor(this.optionTextTransitionColors.normalColor);
            }

            // Add and prepare the text effect
            if (this.optionTextEffectType != OptionTextEffectType.None)
            {
                if (this.optionTextEffectType == OptionTextEffectType.Shadow)
                {
                    Shadow effect = textObject.AddComponent <Shadow>();
                    effect.effectColor     = this.optionTextEffectColor;
                    effect.effectDistance  = this.optionTextEffectDistance;
                    effect.useGraphicAlpha = this.optionTextEffectUseGraphicAlpha;
                }
                else if (this.optionTextEffectType == OptionTextEffectType.Outline)
                {
                    Outline effect = textObject.AddComponent <Outline>();
                    effect.effectColor     = this.optionTextEffectColor;
                    effect.effectDistance  = this.optionTextEffectDistance;
                    effect.useGraphicAlpha = this.optionTextEffectUseGraphicAlpha;
                }
            }

            // Initialize the option component
            optionComp.Initialize(this, text);

            // Set active if it's the selected one
            if (index == this.selectedOptionIndex)
            {
                optionComp.isOn = true;
            }

            // Register to the toggle group
            if (toggleGroup != null)
            {
                optionComp.group = toggleGroup;
            }

            // Hook some events
            optionComp.onSelectOption.AddListener(OnOptionSelect);
            optionComp.onPointerUp.AddListener(OnOptionPointerUp);

            // Add it to the list
            if (this.m_OptionObjects != null)
            {
                this.m_OptionObjects.Add(optionComp);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates new line column object.
        /// </summary>
        /// <param name="parent">Parent.</param>
        /// <param name="content">Content.</param>
        /// <param name="isLeft">If set to <c>true</c> is left.</param>
        /// <param name="style">The style.</param>
        private void CreateLineColumn(Transform parent, string content, bool isLeft, UITooltipLines.LineStyle style)
        {
            // Create the game object
            GameObject obj = new GameObject("Column", typeof(RectTransform), typeof(CanvasRenderer));

            obj.layer = this.gameObject.layer;
            obj.transform.SetParent(parent);

            // Set the pivot to top left
            (obj.transform as RectTransform).pivot = new Vector2(0f, 1f);

            // Set a fixed size for attribute columns
            if (style == UITooltipLines.LineStyle.Attribute)
            {
                VerticalLayoutGroup   vlg  = this.gameObject.GetComponent <VerticalLayoutGroup>();
                HorizontalLayoutGroup phlg = parent.gameObject.GetComponent <HorizontalLayoutGroup>();
                LayoutElement         le   = obj.AddComponent <LayoutElement>();
                le.preferredWidth = (this.m_Rect.sizeDelta.x - vlg.padding.horizontal - phlg.padding.horizontal) / 2f;
            }

            // Prepare the text component
            Text text = obj.AddComponent <Text>();

            text.text            = content;
            text.supportRichText = true;
            text.alignment       = (isLeft) ? TextAnchor.LowerLeft : TextAnchor.LowerRight;

            // Prepare some style properties
            TextEffectType effect         = TextEffectType.None;
            Color          effectColor    = Color.white;
            Vector2        effectDistance = new Vector2(1f, -1f);
            bool           effectUseAlpha = true;

            switch (style)
            {
            case UITooltipLines.LineStyle.Title:
                text.font        = this.m_TitleFont;
                text.fontStyle   = this.m_TitleFontStyle;
                text.fontSize    = this.m_TitleFontSize;
                text.lineSpacing = this.m_TitleFontLineSpacing;
                text.color       = this.m_TitleFontColor;
                effect           = this.m_TitleTextEffect;
                effectColor      = this.m_TitleTextEffectColor;
                effectDistance   = this.m_TitleTextEffectDistance;
                effectUseAlpha   = this.m_TitleTextEffectUseGraphicAlpha;
                break;

            case UITooltipLines.LineStyle.Attribute:
                text.font        = this.m_AttributeFont;
                text.fontStyle   = this.m_AttributeFontStyle;
                text.fontSize    = this.m_AttributeFontSize;
                text.lineSpacing = this.m_AttributeFontLineSpacing;
                text.color       = this.m_AttributeFontColor;
                effect           = this.m_AttributeTextEffect;
                effectColor      = this.m_AttributeTextEffectColor;
                effectDistance   = this.m_AttributeTextEffectDistance;
                effectUseAlpha   = this.m_AttributeTextEffectUseGraphicAlpha;
                break;

            case UITooltipLines.LineStyle.Description:
                text.font        = this.m_DescriptionFont;
                text.fontStyle   = this.m_DescriptionFontStyle;
                text.fontSize    = this.m_DescriptionFontSize;
                text.lineSpacing = this.m_DescriptionFontLineSpacing;
                text.color       = this.m_DescriptionFontColor;
                effect           = this.m_DescriptionTextEffect;
                effectColor      = this.m_DescriptionTextEffectColor;
                effectDistance   = this.m_DescriptionTextEffectDistance;
                effectUseAlpha   = this.m_DescriptionTextEffectUseGraphicAlpha;
                break;
            }

            // Add text effect component
            if (effect == TextEffectType.Shadow)
            {
                Shadow s = obj.AddComponent <Shadow>();
                s.effectColor     = effectColor;
                s.effectDistance  = effectDistance;
                s.useGraphicAlpha = effectUseAlpha;
            }
            else if (effect == TextEffectType.Outline)
            {
                Outline o = obj.AddComponent <Outline>();
                o.effectColor     = effectColor;
                o.effectDistance  = effectDistance;
                o.useGraphicAlpha = effectUseAlpha;
            }
        }
Exemplo n.º 23
0
 void Start()
 {
     _Text             = GetComponent <UnityEngine.UI.Text>();
     _Outline          = GetComponent <UnityEngine.UI.Outline>();
     _InitOutlineColor = _Outline.effectColor;
 }
Exemplo n.º 24
0
 void Start()
 {
     outline         = GetComponent <UnityEngine.UI.Outline>();
     outline.enabled = false;
 }
    /// <summary>
    /// Initialises the script
    /// </summary>
    void Start()
    {
        sm_islandsOwned.Clear();

        m_scoreOutline = scoreText.GetComponent<UnityEngine.UI.Outline>();
        m_scoreTransform = scoreText.GetComponent<RectTransform>();
        scoreText.gameObject.SetActive(false);

        m_nodes = transform.parent.GetComponentsInChildren<IslandDiscoveryNode>();
        foreach(var node in m_nodes)
        {
            node.SetTrigger(this);
        }

        var islands = transform.parent.GetComponentsInChildren<SpriteRenderer>();
        foreach(var island in islands)
        {
            if(island.CompareTag("Island"))
            {
                m_islands.Add(island);
            }
        }

        if(m_islands.Count == 0)
        {
            Debug.LogError("No associated island sprite");
        }
        if(m_nodes.Length == 0)
        {
            Debug.LogError("No associated nodes");
        }

        m_canvas = GetComponent<Canvas>();
        m_canvas.enabled = false;
    }
        /// <summary>
        /// Creates a option.
        /// </summary>
        /// <param name="index">Index.</param>
        protected void CreateOption(int index, ToggleGroup toggleGroup)
        {
            if (this.m_ListObject == null)
            {
                return;
            }

            // Create the option game object with it's components
            GameObject optionObject = new GameObject("Option " + index.ToString(), typeof(RectTransform));

            optionObject.layer = this.gameObject.layer;

            // Change parents
            optionObject.transform.SetParent(this.m_ListObject.transform, false);
            optionObject.transform.localScale = new Vector3(1f, 1f, 1f);

            // Get the option component
            UISelectField_Option optionComp = optionObject.AddComponent <UISelectField_Option>();

            // Prepare the option background
            if (this.optionBackgroundSprite != null)
            {
                Image image = optionObject.AddComponent <Image>();
                image.sprite = this.optionBackgroundSprite;
                image.type   = this.optionBackgroundSpriteType;
                image.color  = this.optionBackgroundSpriteColor;

                // Add the graphic as the option transition target
                optionComp.targetGraphic = image;
            }

            // Prepare the option for animation
            if (this.optionBackgroundTransitionType == Transition.Animation)
            {
                // Attach animator component
                Animator animator = optionObject.AddComponent <Animator>();

                // Set the animator controller
                animator.runtimeAnimatorController = this.optionBackgroundAnimatorController;
            }

            // Apply the option padding
            VerticalLayoutGroup vlg = optionObject.AddComponent <VerticalLayoutGroup>();

            vlg.padding = this.optionPadding;

            // Create the option text
            GameObject textObject = new GameObject("Label", typeof(RectTransform));

            // Change parents
            textObject.transform.SetParent(optionObject.transform, false);

            // Apply pivot
            (textObject.transform as RectTransform).pivot = new Vector2(0f, 1f);

            // Prepare the text
            Text text = textObject.AddComponent <Text>();

            text.font      = this.optionFont;
            text.fontSize  = this.optionFontSize;
            text.fontStyle = this.optionFontStyle;
            text.color     = this.optionColor;

            if (this.options != null)
            {
                text.text = this.options[index];
            }

            // Apply normal state transition color
            if (this.optionTextTransitionType == OptionTextTransitionType.CrossFade)
            {
                text.canvasRenderer.SetColor(this.optionTextTransitionColors.normalColor);
            }

            // Add and prepare the text effect
            if (this.optionTextEffectType != OptionTextEffectType.None)
            {
                if (this.optionTextEffectType == OptionTextEffectType.Shadow)
                {
                    Shadow effect = textObject.AddComponent <Shadow>();
                    effect.effectColor     = this.optionTextEffectColor;
                    effect.effectDistance  = this.optionTextEffectDistance;
                    effect.useGraphicAlpha = this.optionTextEffectUseGraphicAlpha;
                }
                else if (this.optionTextEffectType == OptionTextEffectType.Outline)
                {
                    Outline effect = textObject.AddComponent <Outline>();
                    effect.effectColor     = this.optionTextEffectColor;
                    effect.effectDistance  = this.optionTextEffectDistance;
                    effect.useGraphicAlpha = this.optionTextEffectUseGraphicAlpha;
                }
            }

            // Prepare the option hover overlay
            if (this.optionHoverOverlay != null)
            {
                GameObject hoverOverlayObj = new GameObject("Hover Overlay", typeof(RectTransform));
                hoverOverlayObj.layer = this.gameObject.layer;

                // Add layout element
                LayoutElement hoverLayoutElement = hoverOverlayObj.AddComponent <LayoutElement>();
                hoverLayoutElement.ignoreLayout = true;

                // Change parents
                hoverOverlayObj.transform.SetParent(optionObject.transform, false);
                hoverOverlayObj.transform.localScale = new Vector3(1f, 1f, 1f);

                // Add image
                Image hoImage = hoverOverlayObj.AddComponent <Image>();
                hoImage.sprite = this.optionHoverOverlay;
                hoImage.type   = Image.Type.Sliced;

                // Apply pivot
                (hoverOverlayObj.transform as RectTransform).pivot = new Vector2(0f, 1f);

                // Apply anchors
                (hoverOverlayObj.transform as RectTransform).anchorMin = new Vector2(0f, 0f);
                (hoverOverlayObj.transform as RectTransform).anchorMax = new Vector2(1f, 1f);

                // Apply offsets
                (hoverOverlayObj.transform as RectTransform).offsetMin = new Vector2(0f, 0f);
                (hoverOverlayObj.transform as RectTransform).offsetMax = new Vector2(0f, 0f);

                // Add the highlight transition component
                UISelectField_OptionOverlay hoht = optionObject.AddComponent <UISelectField_OptionOverlay>();
                hoht.targetGraphic = hoImage;
                hoht.transition    = UISelectField_OptionOverlay.Transition.ColorTint;
                hoht.colorBlock    = this.optionHoverOverlayColorBlock;
                hoht.InternalEvaluateAndTransitionToNormalState(true);
            }

            // Prepare the option press overlay
            if (this.optionPressOverlay != null)
            {
                GameObject pressOverlayObj = new GameObject("Press Overlay", typeof(RectTransform));
                pressOverlayObj.layer = this.gameObject.layer;

                // Add layout element
                LayoutElement pressLayoutElement = pressOverlayObj.AddComponent <LayoutElement>();
                pressLayoutElement.ignoreLayout = true;

                // Change parents
                pressOverlayObj.transform.SetParent(optionObject.transform, false);
                pressOverlayObj.transform.localScale = new Vector3(1f, 1f, 1f);

                // Add image
                Image poImage = pressOverlayObj.AddComponent <Image>();
                poImage.sprite = this.optionPressOverlay;
                poImage.type   = Image.Type.Sliced;

                // Apply pivot
                (pressOverlayObj.transform as RectTransform).pivot = new Vector2(0f, 1f);

                // Apply anchors
                (pressOverlayObj.transform as RectTransform).anchorMin = new Vector2(0f, 0f);
                (pressOverlayObj.transform as RectTransform).anchorMax = new Vector2(1f, 1f);

                // Apply offsets
                (pressOverlayObj.transform as RectTransform).offsetMin = new Vector2(0f, 0f);
                (pressOverlayObj.transform as RectTransform).offsetMax = new Vector2(0f, 0f);

                // Add the highlight transition component
                UISelectField_OptionOverlay poht = optionObject.AddComponent <UISelectField_OptionOverlay>();
                poht.targetGraphic = poImage;
                poht.transition    = UISelectField_OptionOverlay.Transition.ColorTint;
                poht.colorBlock    = this.optionPressOverlayColorBlock;
                poht.InternalEvaluateAndTransitionToNormalState(true);
            }

            // Initialize the option component
            optionComp.Initialize(this, text);

            // Set active if it's the selected one
            if (index == this.selectedOptionIndex)
            {
                optionComp.isOn = true;
            }

            // Register to the toggle group
            if (toggleGroup != null)
            {
                optionComp.group = toggleGroup;
            }

            // Hook some events
            optionComp.onSelectOption.AddListener(OnOptionSelect);
            optionComp.onPointerUp.AddListener(OnOptionPointerUp);

            // Add it to the list
            if (this.m_OptionObjects != null)
            {
                this.m_OptionObjects.Add(optionComp);
            }
        }
Exemplo n.º 27
0
 /// <summary>Tweens a Outline's effectColor alpha to the given value.
 /// Also stores the Outline as the tween's target so it can be used for filtered operations</summary>
 /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param>
 public static Tweener DOFade(this  UnityEngine.UI.Outline target, float endValue, float duration)
 {
     return(DOTween.ToAlpha(() => target.effectColor, x => target.effectColor = x, endValue, duration)
            .SetTarget(target));
 }