public Property <T> RegisterProperty <T>(String propertyName) where T : struct { IUpdateable property; if (typeof(T) == typeof(Boolean)) { property = new BoolProperty(this, m_Animator, propertyName); } else if (typeof(T) == typeof(Int32)) { property = new IntProperty(this, m_Animator, propertyName); } else if (typeof(T) == typeof(Single)) { property = new FloatProperty(this, m_Animator, propertyName); } else if (typeof(T) == typeof(Vector3)) { property = new Vector3Property(this, m_Animator, propertyName); } else { if (typeof(T) != typeof(Quaternion)) { throw new NotSupportedException("'" + typeof(T).Name + "' Type not supported!"); } property = new QuaternionProperty(this, m_Animator, propertyName); } m_Properties.Add(propertyName, property); return((Property <T>)property); }
public void SetValue(object value) { string typeName = value.GetType().ToString(); switch (typeName) { case "byte": { if (type == EPropertyType.EPropertyType_Byte) { ByteProperty prop = this as ByteProperty; prop.SetValue((byte)value); return; } } break; case "bool": { if (type == EPropertyType.EPropertyType_Bool) { BoolProperty prop = this as BoolProperty; prop.SetValue((bool)value); return; } } break; case "short": { if (type == EPropertyType.EPropertyType_Short) { ShortProperty prop = this as ShortProperty; prop.SetValue((short)value); return; } } break; case "int": { if (type == EPropertyType.EPropertyType_Int) { IntProperty prop = this as IntProperty; prop.SetValue((int)value); return; } } break; case "long": { if (type == EPropertyType.EPropertyType_Long) { LongProperty prop = this as LongProperty; prop.SetValue((long)value); return; } } break; case "float": { if (type == EPropertyType.EPropertyType_Float) { FloatProperty prop = this as FloatProperty; prop.SetValue((float)value); return; } } break; case "double": { if (type == EPropertyType.EPropertyType_Double) { DoubleProperty prop = this as DoubleProperty; prop.SetValue((double)value); return; } } break; case "Vector2": { if (type == EPropertyType.EPropertyType_Vector2) { Vector2Property prop = this as Vector2Property; prop.SetValue((Vector2)value); return; } } break; case "Vector3": { if (type == EPropertyType.EPropertyType_Vector3) { Vector3Property prop = this as Vector3Property; prop.SetValue((Vector3)value); return; } } break; case "Vector4": { if (type == EPropertyType.EPropertyType_Vector4) { Vector4Property prop = this as Vector4Property; prop.SetValue((Vector4)value); return; } } break; case "Quaternion": { if (type == EPropertyType.EPropertyType_Quaternion) { QuaternionProperty prop = this as QuaternionProperty; prop.SetValue((Quaternion)value); return; } } break; case "Matrix4x4": { if (type == EPropertyType.EPropertyType_Matrix4x4) { Matrix4x4Property prop = this as Matrix4x4Property; prop.SetValue((Matrix4x4)value); return; } } break; case "Color": { if (type == EPropertyType.EPropertyType_Color) { ColorProperty prop = this as ColorProperty; prop.SetValue((Color)value); return; } } break; case "string": { if (type == EPropertyType.EPropertyType_String) { StringProperty prop = this as StringProperty; prop.SetValue((string)value); return; } } break; case "object": { if (type == EPropertyType.EPropertyType_Object) { m_value = value; return; } } break; } return; }
public bool equals(QuaternionProperty other) { return(this.GetValue() == other.GetValue()); }
void Start() { m_sceneController = new SceneController(); BaseState bs = new BaseState(); Property pt1 = new StringProperty("pt1"); Property pt2 = new Vector2Property("vpt"); Property pt3 = new Matrix4x4Property("matpt"); Property pt4 = new QuaternionProperty("qpt"); pt2.value = new Vector2(23, 11); pt1.value = "test"; pt3.value = Matrix4x4.identity; pt4.value = Quaternion.identity; Property pt5 = new ColorProperty("cpt"); Property pt6 = new IntProperty("ipt"); Property pt7 = new Vector3Property("v3pt"); pt5.value = Color.red; pt6.value = 612; pt7.value = new Vector3(12, 11, 33); PropertySet ps = new PropertySet("pset", null); PrpertySetProperty pts = new PrpertySetProperty("pts"); PropertySet ps2 = new PropertySet("pset2", null); ps2.SetProperty(pt5); ps2.SetProperty(pt6); ps2.SetProperty(pt7); pts.value = ps2; ps.SetProperty(pt1); ps.SetProperty(pt2); ps.SetProperty(pt3); ps.SetProperty(pt4); ps.SetProperty(pts); //bs.RegisterProperty(new StringProperty("name")); //bs.SetProperty("name", "lily"); //object v = bs.GetPropertyValue("name"); Property pt = ps.GetProperty("pt1"); Debug.Log(pt.name + " " + pt.value); pt = ps.GetProperty("vpt"); Debug.Log(pt.name + " " + pt.value); pt = ps.GetProperty("matpt"); Debug.Log(pt.name + " " + pt.value); pt = ps.GetProperty("qpt"); Debug.Log(pt.name + " " + pt.value); pt = ps.GetProperty("pts"); PropertySet ps3 = pt.value as PropertySet; pt = ps3.GetProperty("cpt"); Debug.Log(pt.name + " " + pt.value); pt = ps3.GetProperty("ipt"); Debug.Log(pt.name + " " + pt.value); pt = ps3.GetProperty("v3pt"); Debug.Log(pt.name + " " + pt.value); //Debug.Log(pt2.name + " " + pt2.value); //Debug.Log(pt3.name + " " + pt3.value); //Debug.Log(pt4.name + " " + pt4.value); }