public static TypeHandle ValueTypeToTypeHandle(this ValueType valueType) { switch (valueType) { case ValueType.Unknown: return(TypeHandle.Unknown); case ValueType.Bool: return(TypeHandle.Bool); case ValueType.Int: return(TypeHandle.Int); case ValueType.Float: return(TypeHandle.Float); case ValueType.Float2: return(TypeHandle.Vector2); case ValueType.Float3: return(TypeHandle.Vector3); case ValueType.Float4: return(TypeHandle.Vector4); case ValueType.Quaternion: return(TypeHandle.Quaternion); case ValueType.Entity: return(s_EntityTypeHandle); case ValueType.StringReference: return(TypeHandle.String); default: throw new ArgumentOutOfRangeException(nameof(valueType), valueType, null); } }
public static bool TryTypeHandleToValueType(this TypeHandle handle, out ValueType typeHandleToValueType) { typeHandleToValueType = ValueType.Unknown; if (handle == TypeHandle.Unknown) { typeHandleToValueType = ValueType.Unknown; return(true); } if (handle == TypeHandle.Bool) { typeHandleToValueType = ValueType.Bool; return(true); } if (handle == TypeHandle.Int) { typeHandleToValueType = ValueType.Int; return(true); } if (handle == TypeHandle.Float) { typeHandleToValueType = ValueType.Float; return(true); } if (handle == TypeHandle.Vector2) { typeHandleToValueType = ValueType.Float2; return(true); } if (handle == TypeHandle.Vector3) { typeHandleToValueType = ValueType.Float3; return(true); } if (handle == TypeHandle.Vector4) { typeHandleToValueType = ValueType.Float4; return(true); } if (handle == TypeHandle.Quaternion) { typeHandleToValueType = ValueType.Quaternion; return(true); } if (handle == s_EntityTypeHandle) { typeHandleToValueType = ValueType.Entity; return(true); } if (handle == TypeHandle.GameObject) { typeHandleToValueType = ValueType.Entity; return(true); } if (handle == TypeHandle.String) { typeHandleToValueType = ValueType.StringReference; return(true); } return(false); }