예제 #1
0
 public static void Apply(this StyleSheet sheet, StyleValueHandle handle, int specificity, ref Style <float> property)
 {
     if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 2)
     {
         StyleSheetExtensions.Apply <float>(0f, specificity, ref property);
     }
     else
     {
         StyleSheetExtensions.Apply <float>(sheet.ReadFloat(handle), specificity, ref property);
     }
 }
예제 #2
0
 public static void Apply <T>(this StyleSheet sheet, StyleValueHandle handle, int specificity, ref Style <int> property) where T : struct
 {
     if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 2)
     {
         StyleSheetExtensions.Apply <int>(0, specificity, ref property);
     }
     else
     {
         StyleSheetExtensions.Apply <int>(StyleSheetCache.GetEnumValue <T>(sheet, handle), specificity, ref property);
     }
 }
예제 #3
0
 public static void Apply(this StyleSheet sheet, StyleValueHandle handle, int specificity, ref Style <Color> property)
 {
     if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 2)
     {
         StyleSheetExtensions.Apply <Color>(default(Color), specificity, ref property);
     }
     else
     {
         StyleSheetExtensions.Apply <Color>(sheet.ReadColor(handle), specificity, ref property);
     }
 }
예제 #4
0
        public static void Apply(this StyleSheet sheet, StyleValueHandle handle, int specificity, ref Style <bool> property)
        {
            bool val = sheet.ReadKeyword(handle) == StyleValueKeyword.True;

            if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 2)
            {
                StyleSheetExtensions.Apply <bool>(false, specificity, ref property);
            }
            else
            {
                StyleSheetExtensions.Apply <bool>(val, specificity, ref property);
            }
        }
예제 #5
0
 public static void Apply <T>(this StyleSheet sheet, StyleValueHandle handle, int specificity, LoadResourceFunction loadResourceFunc, ref Style <T> property) where T : UnityEngine.Object
 {
     if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 5)
     {
         StyleSheetExtensions.Apply <T>((T)((object)null), specificity, ref property);
     }
     else
     {
         string text = sheet.ReadResourcePath(handle);
         if (!string.IsNullOrEmpty(text))
         {
             T t = loadResourceFunc(text, typeof(T)) as T;
             if (t != null)
             {
                 StyleSheetExtensions.Apply <T>(t, specificity, ref property);
             }
             else
             {
                 Debug.LogWarning(string.Format("{0} resource not found for path: {1}", typeof(T).Name, text));
             }
         }
     }
 }