public static Color AsColor(this UssValue v) { v = v.Unwrap(); if (v.GetType() == typeof(UssColorValue)) { return(((UssColorValue)v).value); } if (v.GetType() == typeof(UssStringValue)) { var str = v.AsString(); if (str == "black") { return(Color.black); } else if (str == "green") { return(Color.green); } else if (str == "red") { return(Color.red); } else if (str == "blue") { return(Color.blue); } } throw new InvalidOperationException("Value cannot be color: " + v.GetType()); }
public static Color AsColor(this UssValue v) { v = v.Unwrap(); if (v.GetType() == typeof(UssColorValue)) { return(((UssColorValue)v).value); } throw new InvalidOperationException("Value cannot be color: " + v.GetType()); }
public static int AsInt(this UssValue v) { v = v.Unwrap(); if (v.GetType() == typeof(UssFloatValue)) { return((int)((UssFloatValue)(object)v).value); } if (v.GetType() == typeof(UssIntValue)) { return(((UssIntValue)(object)v).value); } throw new InvalidOperationException("Value cannot be integer: " + v.GetType()); }
public static string AsString(this UssValue v) { v = v.Unwrap(); if (v.GetType() == typeof(UssStringValue)) { return(((UssStringValue)(object)v).value); } if (v.GetType() == typeof(UssNullValue)) { return(null); } throw new InvalidOperationException("Value cannot be string: " + v.GetType()); }