Beispiel #1
0
    void SpawnWithData(ObjectInfoSaveLoad loadedClass)
    {
        List <ObjectInfo> infoList = loadedClass.GetInfoList();

        for (int i = 0; i < infoList.Count; i++)
        {
            ObjectInfo info = infoList[i];

            Vector3 pos         = info.GetPosition();
            Vector3 rot         = info.GetRotation();
            Vector3 velo        = info.GetVelocity();
            Vector3 angularVelo = info.GetAngularVelocity();
            Color   color       = info.GetColor();
            int     shapeId     = info.GetShapeId();

            GameObject obj;

            if (shapeId == 0)
            {
                obj = Instantiate(cubePrefab);
            }
            else
            {
                obj = Instantiate(spherePrefab);
            }

            obj.transform.name        = shapeId.ToString();
            obj.transform.position    = pos;
            obj.transform.eulerAngles = rot;
            obj.GetComponent <MeshRenderer>().material.color = color;
            obj.GetComponent <Rigidbody>().velocity          = velo;
            obj.GetComponent <Rigidbody>().angularVelocity   = angularVelo;

            allObjects.Add(obj);
        }
    }