UnityEngine.GameObject.CreatePrimitive C# (CSharp) Method

CreatePrimitive() public static method

public static CreatePrimitive ( PrimitiveType type ) : GameObject
type PrimitiveType
return GameObject
		public static GameObject CreatePrimitive(PrimitiveType type){}
		public Component GetComponent(Type type){}

Usage Example

示例#1
0
    public static Unit SpawnCube(V3 pos)
    {
        var obj = Gobj.CreatePrimitive(PrimitiveType.Cube);

        obj.transform.position = pos;
        var p = obj.transform.position;

        obj.transform.position   = new V3(p.x, p.y, CameraOffset);
        obj.transform.localScale = new V3(0.1f, 0.1f, 0.1f);
        var unit = obj.AddComponent <Unit>( );

        return(unit);
    }