create a cube at the position 0 10 0 in csharp

To create a cube at position (0, 10, 0) in C# in Unity, you can use the following code:

main.cs
using UnityEngine;

public class CubeCreator : MonoBehaviour
{
    void Start()
    {
        // Create a cube at position (0, 10, 0)
        GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        cube.transform.position = new Vector3(0, 10, 0);
    }
}
273 chars
12 lines

Just make sure to attach this script to a game object in your scene, or create an empty object and attach the script to it before running the game. This will create a cube at the specified position while the game is running.

gistlibby LogSnag