/// <summary> /// Create new shape. /// </summary> public void CreateShape() { lastCorrectSFXIndex = 0; winDialog.Hide(); DestroyOldShape(); try { GameObject shapePrefab = getRandomShape(); GameObject shapeGameObject = Instantiate(shapePrefab, Vector3.zero, Quaternion.identity) as GameObject; shapeGameObject.transform.SetParent(shapeParent); shapeGameObject.transform.localPosition = shapePrefab.transform.localPosition; shapeGameObject.name = shapePrefab.name; shapeGameObject.transform.localScale = shapePrefab.transform.localScale; shape = GameObject.FindObjectOfType <TR_Shape>(); } catch (System.Exception ex) { Debug.LogError("Create Shape Error: " + ex.Message); } if (shape == null) { return; } shape.Spell(); EnableGameManager(); }
public void DestroyOldShape() { if (shape != null && shape.transform.parent == shapeParent) { shape.transform.parent = null; } if (shape != null) { // Destroy (shape.gameObject); } shape = null; }
public void loadShape(TR_Shape newShape) { lastCorrectSFXIndex = 0; winDialog.Hide(); DestroyOldShape(); if (newShape == null) { return; } newShape.transform.SetParent(shapeParent, true); // shapeGameObject.transform.localPosition = shapePrefab.transform.localPosition; // shapeGameObject.name = shapePrefab.name; // shapeGameObject.transform.localScale = shapePrefab.transform.localScale; shape = newShape; //GameObject.FindObjectOfType<TR_Shape> (); shape.Spell(); EnableGameManager(); }