/*******************************************************/ /* !@brief : プレハブからオブジェクトをインスタンス * @param[in] : path -> リソースパス * @param[in] : type -> リソースタイプ * @param[in] : parent -> 親オブジェクトのTransform * @retval : Object * @date : 2014/05/02 * @author : コロソブス(korombus) *******************************************************/ public GameObject PrefabInstanceObj(UnityEngine.MonoBehaviour MBeh, string path, Transform parent, string objName) { MBeh.StartCoroutine(create(MBeh, path, typeof(GameObject), parent)); GameObject obj = data as GameObject; obj.name = objName; return obj; }
/*******************************************************/ /* !@brief : リソースロード * @param[in] : path -> リソースパス * @param[in] : type -> リソースタイプ * @retval : Object * @date : 2014/05/02 * @author : コロソブス(korombus) *******************************************************/ public object Load(UnityEngine.MonoBehaviour MBeh, string path, System.Type type) { data = null; MBeh.StartCoroutine(create(MBeh, path, type)); Debug.Log(data); return data; }
private void InvokeRpcMethod(UnityEngine.MonoBehaviour target, MethodInfo methodInfo, object[] parameters) { ParameterInfo[] callMethodParameters = methodInfo.GetParameters(); for(int i = 0; i < callMethodParameters.Length; i++) { ParameterInfo info = callMethodParameters[i]; if(!info.ParameterType.IsAssignableFrom(typeof(PhotonView)) && info.ParameterType.IsAssignableFrom(typeof(UnityEngine.Component))) { object parameter = parameters[i]; if (parameters == null) continue; PhotonView view = parameter as PhotonView; Assert.IsNotNull(view, "View was null when it should not have been."); Component component = view.GetComponent(info.ParameterType); Assert.IsNotNull(component); parameters[i] = component; } else if(info.ParameterType.IsArray && !info.ParameterType.GetElementType().IsAssignableFrom(typeof(PhotonView)) && info.ParameterType.GetElementType().IsAssignableFrom(typeof(UnityEngine.Component))) { object parameterArray = parameters[i]; if (parameterArray == null) continue; PhotonView[] views = parameterArray as PhotonView[]; Assert.IsNotNull(views); Array components = Array.CreateInstance(info.ParameterType.GetElementType(), views.Length); ; for(int j = 0; j < views.Length; j++) { PhotonView view = views[j]; if (!view) components.SetValue(null, j); else components.SetValue(view.GetComponent(info.ParameterType.GetElementType()), j); } } } object result = methodInfo.Invoke(target, parameters); if (methodInfo.ReturnType == typeof(IEnumerator)) { target.StartCoroutine((IEnumerator)result); } }