Пример #1
0
    public void CreateCube()
    {
        GameObject cubeObject = Instantiate(testCubePrefab, RandomVector3, RandomQuaternion);

        TestPort.CubeEntity cubeEntity    = world.createEntity <TestPort.CubeEntity>("Test Cube");
        EcsTestCube         ecsCubeObject = cubeObject.GetComponent <EcsTestCube>();

        ecsCubeObject.AssignEntity(cubeEntity);
        cubeEntity.name += cubeEntity.id;
        cubeObject.name  = cubeEntity.name;
        testCubes.Add(ecsCubeObject);
    }
Пример #2
0
    public void AssignEntity(TestPort.CubeEntity entity)
    {
        cubeEntity = entity;

        // Assign position
        TestPort.PositionComponent pc = entity.Position;
        Vector3 pos = transform.position;

        pc.x = pos.x;
        pc.y = pos.y;
        pc.z = pos.z;

        // Assign Rotation
        TestPort.RotationComponent rc = entity.Rotation;
        Vector3 rot = transform.rotation.eulerAngles;

        pc.x = pos.x;
        pc.y = pos.y;
        pc.z = pos.z;
    }