Esempio n. 1
0
    GameObject createObject(ObjectState ob)
    {
        GameObject    gameOb;
        bool          isBox         = ob.GetType().Equals(typeof(BoxObject));
        PrimitiveType primitiveType = isBox ? PrimitiveType.Cube : PrimitiveType.Sphere;

        if (ob.mesh != null)
        {
            UnityEngine.Object prefab = Resources.Load(ob.mesh); // Assets/Resources/Prefabs/prefab1.FBX
            if (prefab == null)
            {
                gameOb = GameObject.CreatePrimitive(primitiveType);
                Debug.Log("Couldnt find " + ob.mesh);
            }
            else
            {
                gameOb = (GameObject)Instantiate(prefab);
            }
        }
        else
        {
            gameOb = GameObject.CreatePrimitive(primitiveType);
        }
        gameOb.name = "Object (" + ob.uID + ")" + ob.GetType().ToString();
        Vector3 size;

        if (isBox)
        {
            BoxObject boxState = (BoxObject)ob;

            size = new Vector3(boxState.halfSize.x, boxState.halfSize.y, boxState.halfSize.z);
        }
        else
        {
            SphereObject boxState = (SphereObject)ob;
            size = new Vector3(boxState.radius * 2, boxState.radius * 2, boxState.radius * 2);
        }

        //size.Scale(new Vector3(2, 2, 2));
        if (ob.type == "QuixBox")
        {
            Debug.Log("Este 2" + size);
        }
        gameOb.transform.localScale = size;
        gameOb.transform.parent     = ServerObjects.transform;
        return(gameOb);
    }
Esempio n. 2
0
 private bool isBox()
 {
     return(state.GetType().Equals(typeof(BoxObject)));
 }