private bool CreateSphere() { DestroyObject(); CurGameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere); InitObject(); CurGameObject.AddComponent <GameSphere>(); CurGameObject.GetComponent <GameSphere>().ObjectLogic = this; return(true); }
private bool DropObject() { if (CurGameObject != null) { Rigidbody rigidbody = CurGameObject.GetComponent <Rigidbody>() as Rigidbody; rigidbody.useGravity = true; } return(true); }
private void InitObject() { Material defaultMaterial = null; foreach (var it in Resources.FindObjectsOfTypeAll(typeof(Material))) { if (it.name == PLAYER_MAT_NAME) { defaultMaterial = it as Material; break; } } CurGameObject.transform.position = INIT_POS; CurGameObject.GetComponent <MeshRenderer>().material = defaultMaterial; Rigidbody rigidbody = CurGameObject.AddComponent <Rigidbody>() as Rigidbody; rigidbody.useGravity = false; rigidbody.mass = 1; }