コード例 #1
0
        public bool TryGetExtraCastedStyleProperty(string p_name, out T p_styleProperty)
        {
            StyleProperty v_property = null;
            var           v_sucess   = ExtraStylePropertiesMap.TryGetValue(p_name, out v_property);

            p_styleProperty = v_property as T;

            return(v_sucess);
        }
コード例 #2
0
        protected virtual bool LoadGenericStyles(StyleData p_styleData)
        {
            //Cache StyleData Asset
            _styleData = p_styleData;

            var v_template = p_styleData != null ? p_styleData.Asset : null;

            if (v_template != null)
            {
                Dictionary <string, StyleProperty>[] v_otherStyleMaps = new Dictionary <string, StyleProperty>[] { v_template.ExtraStylePropertiesMap };
                Dictionary <string, StyleProperty>[] v_selfStyleMaps  = new Dictionary <string, StyleProperty>[] { ExtraStylePropertiesMap };

                for (int i = 0; i < v_otherStyleMaps.Length; i++)
                {
                    //Apply Style Properties
                    foreach (var v_pair in v_otherStyleMaps[i])
                    {
                        StyleProperty v_selfStyleProperty = null;
                        v_selfStyleMaps[i].TryGetValue(v_pair.Key, out v_selfStyleProperty);
                        if (v_selfStyleProperty != null && v_pair.Value != null)
                        {
                            var v_otherStyleProperty = v_pair.Value;
                            v_selfStyleProperty.LoadStyles(v_otherStyleProperty);


                            //Disable/Enable GameObject based in Template (prevent apply if selfStyleProperty.Target is self transform)
                            if (v_selfStyleProperty.Target != this.transform && v_selfStyleProperty.Target != null && v_otherStyleProperty.Target != null)
                            {
                                StyleUtils.ApplyObjectActive(v_selfStyleProperty.Target, v_otherStyleProperty.Target);
                            }

                            //Apply Graphic if Supported
                            if (v_selfStyleProperty.UseStyleGraphic)
                            {
                                StyleUtils.ApplyGraphic(v_selfStyleProperty.Target, v_otherStyleProperty.Target);
                            }
                        }
                    }
                }

                var v_metaType = StyleMetaType.GetOrCreateStyleMetaType(GetType());
                v_metaType.ApplyStyleDataToTarget(this, p_styleData);

#if UNITY_EDITOR
                UnityEditor.EditorUtility.SetDirty(this);
#endif

                return(true);
            }
            return(false);
        }
コード例 #3
0
        public virtual bool LoadStyles(StyleProperty p_styleProperty)
        {
            var v_metaType = StyleMetaType.GetOrCreateStyleMetaType(GetType());

            return(v_metaType.ApplyTemplateToTarget(this, p_styleProperty));
        }
コード例 #4
0
 public bool TryGetExtraStyleProperty(string p_name, out StyleProperty p_styleProperty)
 {
     return(ExtraStylePropertiesMap.TryGetValue(p_name, out p_styleProperty));
 }