相关疑难解决方法(0)

使用Unity在C#中发送http请求

如何使用Unity在C#中发送HTTP GET和POST请求?

我想要的是:

  • 在post请求中发送json数据(我使用Unity序列化器,因此不需要新的,我只想在post数据中传递字符串并且能够将ContentType设置为application/json);
  • 获得响应代码和正文没有任何问题;
  • 在不阻止ui渲染的情况下完成异步操作.

我尝试过的:

  • 使用HttpWebRequest/HttpWebResponse实现,但它太难和低级别(如果我找不到更好的东西,我将不得不使用它);
  • 使用统一WWW,但它不符合我的要求;
  • 使用NuGet的一些外部包 - Unity不接受它们:(

大多数问题都是使用线程,我在C#中没有足够的经验.我使用的文本编辑器是Intellij Rider.

c# http unity-game-engine

24
推荐指数
1
解决办法
2万
查看次数

Component,Behavior和MonoBehaviour有什么区别?为什么这些是分开的?

MonoBehaviour扩展了行为和行为扩展组件.我想知道为什么这些类是分开的和这些类的语义含义.是否有任何分离这些课程的目的?是否有任何类直接扩展行为或组件?

我知道我们必须使用MonoBehaviour在Unity中创建C#代码.但是,我对Unity作为游戏引擎的架构感兴趣.

c# architecture unity-game-engine

12
推荐指数
1
解决办法
3490
查看次数

创建协程以淡出不同类型的对象

嗨,我正在尝试统一创建一个协程,以处理各种物体上的褪色。到目前为止,我已经能够获得所需的不同类型的Alpha值,但是在使用新颜色后如何设置它还处于死胡同。这是我的代码:

public static  IEnumerator FadeTo(float aValue, float aTime,GameObject gameObj)
            {
                Component[] allComponents = gameObj.GetComponents(typeof(Component));
                Component fadableComponent;
                Type type = null;
                float alpha=0;
                foreach(Component c in allComponents)
                {
                    if(c.GetType()==typeof(Image))
                    {
                        fadableComponent = c;
                        alpha = fadableComponent.GetComponent<Image>().color.a;
                        type = fadableComponent.GetType();
                        Debug.Log("Found a image");
                        break;
                    }
                    if (c.GetType() == typeof(Renderer))
                    {
                        fadableComponent = c;
                        alpha = fadableComponent.GetComponent<Renderer>().material.color.a;
                        type = fadableComponent.GetType();
                        break;
                    }
                    if (c.GetType() == typeof(SpriteRenderer))
                    {
                        fadableComponent = c;
                        alpha = fadableComponent.GetComponent<SpriteRenderer>().color.a;
                        type = fadableComponent.GetType();
                        break;
                    }
                    if(c.GetType()== typeof(CanvasGroup))
                    {
                        fadableComponent = …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

2
推荐指数
1
解决办法
874
查看次数

标签 统计

c# ×3

unity-game-engine ×3

architecture ×1

http ×1