我有以下方法:
// Get Player Avatar
public void GetAvatar(Action<AvatarResponse> onComplete = null){
if(!validate()){return;}
Send(endpoint_getAvatar, onComplete);
}
调用此方法:
protected void Send(string endpoint, Action<GameSmartResponse> onComplete = null){
WWWForm form = new WWWForm();
StartCoroutine(Request(endpoint, form, onComplete));
}
然后运行此方法:
IEnumerator Request(string endpoint, WWWForm form, Action<GameSmartResponse> onComplete = null){
WWW www = new WWW(url + endpoint, form);
yield return www;
if(onComplete != null){
onComplete(JsonUtility.FromJson<GameSmartResponse>(www.text));
}
}
AvatarResponse
[System.SerializableAttribute]
public class AvatarResponse : GameSmartResponse {
public string avatar;
public static AvatarResponse CreateFromJSON(string jsonString){
return JsonUtility.FromJson<AvatarResponse>(jsonString);
}
}
然后我从GetAvatar
方法
Argument 2: cannot convert from
'System.Action<GameSmartSdk.AvatarResponse>' to
'System.Action<GameSmartSdk.GameSmartResponse>'
我认为如果我扩展了对象,我可以在<>
内使用它,那为什么它会给我这个错误呢?