コード例 #1
0
 //instantiates a new mesh object prefab with all its scripts
 public void SpawnNewMesh()
 {
     //Debug.Log (clone);
     newgameSound.Play();
     if (clone == null)
     {
         clone = (GameObject)Instantiate(Resources.Load("TexturePainter-Instances/Sphere"), SpawnPosition);
         clone.GetComponent <GenerateSphere> ().GenerateMesh();
         UIref.assignedAllUI();
         PMD.AssignedAllReference();
         meshTrans = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
         meshTrans.AssignedMeshTrasformReference();
         undoNredo.assignedReference();
         dm.assignedUIObjects();
         //Debug.Log ("spawned");
         newGamePressed = true;
     }
     else
     {
         Destroy(clone);
         clone = (GameObject)Instantiate(Resources.Load("TexturePainter-Instances/Sphere"), SpawnPosition);
         clone.GetComponent <GenerateSphere> ().GenerateMesh();
         UIref.assignedAllUI();
         PMD.AssignedAllReference();
         meshTrans = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
         meshTrans.AssignedMeshTrasformReference();
         undoNredo.assignedReference();
         dm.assignedUIObjects();
         //Debug.Log ("Object already instantiated");
         newGamePressed = true;
     }
 }
コード例 #2
0
 // Update is called once per frame
 void FixedUpdate()
 {
     try{
         if (newGamePressed)
         {
             if (meshTrans == null)
             {
                 meshTrans = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
                 meshTrans.AssignedMeshTrasformReference();
             }
         }
     }catch (Exception ex) {
         if (ex is NullReferenceException || ex is UnassignedReferenceException)
         {
             return;
         }
     }
 }