【问题标题】:The name `instance' does not exist in the current context当前上下文中不存在名称“实例”
【发布时间】:2013-11-29 18:55:16
【问题描述】:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;

public class NetManager : MonoBehaviour
{   
        // URL can be also locale : "file://C:\file.xml"
        private static string URL = "http://www.domain.com/file.xml";

        private XMLManager.Player player = null;

        void Start() {
            StartCoroutine (instance.RetrieveNextPlayerCoroutine (callback));
        }

        // ----------- Retrieve Player -------------- //

        public delegate void RetrieveNextPlayerCallback (XMLManager.Player result);

        private IEnumerator RetrieveNextPlayerCoroutine (RetrieveNextPlayerCallback callback)
        {
                WWW www = new WWW (URL);
                yield return www;
                if (www.error == null) {
                        player = XMLManager.ParsePlayerXML (www.text);
                } else { 
                        Debug.Log (www.error);
                }
        }
}

我已经获得了一个用于统一的 xml 解析器。我收到了这个错误,但我不知道如何解决它。任何建议都会有所帮助:/

【问题讨论】:

  • 嗯,是的 - 您正在调用 instance.RetrieveNextPlayerCoroutine - 但您没有名为 instance 的变量。
  • 发布代码时,请将其发布在本网站上,而不是链接到包含代码的外部网站。我编辑了您的帖子以将代码移至此处。
  • 邮件的哪一部分你不明白?
  • @JohnKoerner - 道歉
  • @SLaks - 我刚得到这个,我被告知只需插入并使用它,我没有写它,而且我不熟悉 C#,所以我不真的不知道这里发生了什么

标签: c# xml parsing xml-parsing unity3d


【解决方案1】:

Start 方法中的变量 instance 从未声明过,这正是错误告诉您的内容。

【讨论】:

    猜你喜欢
    • 2020-10-28
    • 2013-10-02
    • 2014-04-22
    • 2017-06-17
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-18
    相关资源
    最近更新 更多