public object Get(string name, System.Type type) { object obj = null; if (type == typeof(UnityEngine.Object) || type.IsSubclassOf(typeof(UnityEngine.Object))) { obj = objects.Get(name); } else if (type == typeof(float)) { obj = floats.Get(name); } else if (type == typeof(int)) { obj = ints.Get(name); } else if (type == typeof(string)) { obj = strings.Get(name) ?? string.Empty; } else if (type == typeof(bool)) { obj = bools.Get(name); } else if (type.IsSubclassOf(typeof(System.Enum))) { obj = enums.Get(name); } else if (type == typeof(Vector3)) { obj = vector3s.Get(name); } else if (type == typeof(Vector2)) { obj = vector2s.Get(name); } else if (type == typeof(Vector4)) { obj = vector4s.Get(name); } else if (type == typeof(Color)) { obj = colors.Get(name); } else if (type == typeof(LayerMaskMap)) { obj = layerMasks.Get(name); } else { throw new NotSupportedException($"Type {type.AssemblyQualifiedName} is not supported. ({name})"); } if (obj == null && type.IsValueType) { return(Activator.CreateInstance(type)); } return(obj); }
public LColor GetColor(float r, float g, float b, float a) { if (a <= 0.1f) { return(alphaColor); } int hashCode = 1; hashCode = LSystem.Unite(hashCode, r); hashCode = LSystem.Unite(hashCode, g); hashCode = LSystem.Unite(hashCode, b); hashCode = LSystem.Unite(hashCode, a); LColor color = colorMap.Get(hashCode); if (color == null) { color = new LColor(r, g, b, a); colorMap.Put(hashCode, color); } return(color); }