/// <summary> /// Gets object by type. /// for concrete type e.g. setInt32 setString, they know how to return object /// /// but for T parameters, type is unknown until runtime /// so this function needs a 'Type' argument /// which is passed through mTempObj /// </summary> /// <param name="eType">Type of the e.</param> /// <returns></returns> public object getByType(JSApi.GetType eType) { int e = (int)eType; Type type = (Type)mTempObj; if (type.IsByRef) { type = type.GetElementType(); } if (type == typeof(string)) { return(JSApi.getStringS(e)); } else if (type.IsEnum) { return(JSApi.getEnum(e)); } else if (type.IsPrimitive) { if (type == typeof(System.Boolean)) { return(JSApi.getBooleanS(e)); } else if (type == typeof(System.Char)) { return(JSApi.getChar(e)); } else if (type == typeof(System.Byte)) { return(JSApi.getByte(e)); } else if (type == typeof(System.SByte)) { return(JSApi.getSByte(e)); } else if (type == typeof(System.UInt16)) { return(JSApi.getUInt16(e)); } else if (type == typeof(System.Int16)) { return(JSApi.getInt16(e)); } else if (type == typeof(System.UInt32)) { return(JSApi.getUInt32(e)); } else if (type == typeof(System.Int32)) { return(JSApi.getInt32(e)); } else if (type == typeof(System.UInt64)) { return(JSApi.getUInt64(e)); } else if (type == typeof(System.Int64)) { return(JSApi.getInt64(e)); } else if (type == typeof(System.Single)) { return(JSApi.getSingle(e)); } else if (type == typeof(System.Double)) { return(JSApi.getDouble(e)); } else if (type == typeof(System.IntPtr)) { return(JSApi.getIntPtr(e)); } else { Debug.LogError("Unknown primitive type" + type.Name); } } // else if (type == typeof(Vector2)) // { // return JSApi.getVector2S(e); // } // else if (type == typeof(Vector3)) // { // return JSApi.getVector3S(e); // } else { return(JSApi.getObject(e)); } return(null); }
/// <summary> /// Gets object by type. /// for concrete type e.g. setInt32 setString, they know how to return object /// but for T parameters, type is unknown until runtime /// so this function needs a 'Type' argument /// which is passed through mTempObj /// </summary> /// <param name="eType">Type of the e.</param> /// <returns></returns> public object getByType(JSApi.GetType eType) { int e = (int)eType; Type type = null; if (type.IsByRef) { type = type.GetElementType(); } if (type == typeof(string)) { return(JSApi.getStringS(e)); } if (type.IsEnum) { return(JSApi.getEnum(e)); } if (type.IsPrimitive) { if (type == typeof(bool)) { return(JSApi.getBooleanS(e)); } if (type == typeof(char)) { return(JSApi.getChar(e)); } if (type == typeof(byte)) { return(JSApi.getByte(e)); } if (type == typeof(sbyte)) { return(JSApi.getSByte(e)); } if (type == typeof(ushort)) { return(JSApi.getUInt16(e)); } if (type == typeof(short)) { return(JSApi.getInt16(e)); } if (type == typeof(uint)) { return(JSApi.getUInt32(e)); } if (type == typeof(int)) { return(JSApi.getInt32(e)); } if (type == typeof(ulong)) { return(JSApi.getUInt64(e)); } if (type == typeof(long)) { return(JSApi.getInt64(e)); } if (type == typeof(float)) { return(JSApi.getSingle(e)); } if (type == typeof(double)) { return(JSApi.getDouble(e)); } if (type == typeof(IntPtr)) { return(JSApi.getIntPtr(e)); } Debug.LogError("Unknown primitive type" + type.Name); } else if (type == typeof(Vector2)) { return(JSApi.getVector2S(e)); } else if (type == typeof(Vector3)) { return(JSApi.getVector3S(e)); } else { return(JSApi.getObject(e)); } return(null); }