【问题标题】:Simple server for Unity games [closed]Unity游戏的简单服务器[关闭]
【发布时间】:2018-03-22 12:54:44
【问题描述】:

是否有任何现有服务可以帮助为 Unity 游戏构建简单的服务器?我想要的只是制作一个应用程序来请求和接收来自网络的图像和一些文本并将其显示给用户。因此,当我在服务器端更改图像和文本时,我所有的应用程序都会显示新的图片和文本。谢谢

【问题讨论】:

    标签: api unity3d server client-server


    【解决方案1】:

    您可以简单地将您想要的图像和文本放在标准网络服务器上,然后您可以使用 Unity 的 WWW 类来访问它。例如,“http://example.com/unitygametext.txt”和“http://example.com/image.png”。

    Unity 的文档有some examples on how to get textures and text:

    IEnumerator Start() {
        using (WWW www = new WWW("http://example.com/image.png")) {
            yield return www;
            Renderer renderer = GetComponent<Renderer>();
            renderer.material.mainTexture = www.texture;
        }
    }
    

    对于文本,您只需将 WWW.texture 替换为 WWW.text

    【讨论】:

      【解决方案2】:

      因为您要求的只是一个 http 服务器,您可以使用 WWW Class 连接到您的服务器

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多