Ejemplo n.º 1
0
        /// <summary>
        /// Set the specified style.
        /// </summary>
        /// <returns><c>true</c>, if style was set for children gameobjects, <c>false</c> otherwise.</returns>
        /// <param name="style">Style data.</param>
        public virtual bool SetStyle(Style style)
        {
            var stylable = Compatibility.GetComponent <IStylable>(tooltipObject);

            if (stylable != null)
            {
                stylable.SetStyle(style);
            }
            else
            {
                style.Tooltip.Background.ApplyTo(tooltipObject);
                style.Tooltip.Text.ApplyTo(tooltipObject.transform.Find("Text"));
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Is target height under layout group or fitter control?
        /// </summary>
        /// <param name="target">Target.</param>
        /// <returns>true if target height under layout group or fitter control; otherwise false.</returns>
        public static bool IsHeightControlled(RectTransform target)
        {
            var ignorer = Compatibility.GetComponent <ILayoutIgnorer>(target);

            if ((ignorer != null) && ignorer.ignoreLayout)
            {
                return(false);
            }

            var fitter = target.GetComponent <ContentSizeFitter>();

            if ((fitter != null) && (fitter.verticalFit != ContentSizeFitter.FitMode.Unconstrained))
            {
                return(true);
            }

            var parent = target.transform.parent as RectTransform;

            if (parent != null)
            {
                var layout_group = parent.GetComponent <LayoutGroup>();
                if (layout_group == null)
                {
                    return(false);
                }

                var g_layout_group = layout_group as GridLayoutGroup;
                if ((g_layout_group != null) && g_layout_group.enabled)
                {
                    return(true);
                }

                var hv_layout_group = layout_group as HorizontalOrVerticalLayoutGroup;
                if ((hv_layout_group != null) && hv_layout_group.enabled)
                {
                    return(Compatibility.GetLayoutChildControlHeight(hv_layout_group));
                }

                var e_layout_group = layout_group as EasyLayout;
                if ((e_layout_group != null) && e_layout_group.enabled)
                {
                    return(e_layout_group.ChildrenHeight != ChildrenSize.DoNothing);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Init InputField.
        /// </summary>
        protected void InitInputField()
        {
            inputField = Compatibility.GetComponent <IInputFieldExtended>(this);

            if (inputField == null)
            {
                var input = gameObject.AddComponent <InputFieldExtended>();
                input.textComponent = m_TextComponent;
                input.placeholder   = m_Placeholder;
                input.targetGraphic = m_TargetGraphic;

                input.onEndEdit = m_OnEndEdit;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                input.onValueChanged = m_OnValueChanged;
#else
                input.onValueChange = m_OnValueChanged;
#endif

                inputField = input;
            }
        }