小编Naw*_*waf的帖子

在Unity 2D中移动简单对象

我试图Object在Unity中移动一个简单但我收到以下错误消息:

cannot modify the return value of unityengine.transform.position because itar is not variable

这是我的代码:

using UnityEngine;
using System.Collections;

public class walk : MonoBehaviour {
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

        float movespeed = 0.0f;
        movespeed++;
        transform.position.x  = transform.position.x + movespeed;

    }
}
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

8
推荐指数
1
解决办法
4万
查看次数

呼叫功能有什么错误?

我试图在Unity环境中调用一个用c#编写的示例函数.我收到此错误消息:

多成员名称不能与其封闭类型相同

这是我正在使用的代码:

using UnityEngine;
using System.Collections;

public class multi : MonoBehaviour {
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        int x = 5;
        multi (x);
    }

    int multi ( int tem ){
        int ret ;
        ret = tem * 2 ; 
        return ret;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# function

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

标签 统计

c# ×2

function ×1

unity-game-engine ×1