操作无法从A转换为B.

时间:2016-03-14 16:51:08

标签: c# unity3d

我有以下方法:

// 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>'

我认为如果我扩展了对象,我可以在<>内使用它,那为什么它会给我这个错误呢?

0 个答案:

没有答案