void CheckSignAvailability() { if (gameObject.layer == LayerMask.NameToLayer("enemy")) { return; } if (sign == null) { return; } if (currentSign == signType) { return; } if (currentSign != SignsController.SignType.None) { Destroy(signObject); } currentSign = signType; if (currentSign == SignsController.SignType.None) { return; } SignsController controller = transform.parent.GetComponent <SignsController>(); GameObject signPrefab = null; if (currentSign == SignsController.SignType.Triangle) { signPrefab = ((Sign)controller.triangleSign).prefab; signObject = Instantiate(signPrefab) as GameObject; } else if (currentSign == SignsController.SignType.Rectangle) { signPrefab = ((Sign)controller.rectangleSign).prefab; signObject = Instantiate(signPrefab) as GameObject; } else if (currentSign == SignsController.SignType.Barrier) { signPrefab = ((Sign)controller.barrierSign).prefab; signObject = Instantiate(signPrefab) as GameObject; } signObject.transform.parent = sign; signObject.transform.localPosition = new Vector3(0, 0, 0); signObject.transform.localEulerAngles = new Vector3(0, 0, 0); signObject.transform.localScale = signPrefab.transform.localScale; }
void CheckSignAvailability() { if (gameObject.layer == LayerMask.NameToLayer ("enemy")) return; if (sign == null) return; if (currentSign == signType) return; if (currentSign != SignsController.SignType.None) { Destroy (signObject); } currentSign = signType; if (currentSign == SignsController.SignType.None) return; SignsController controller = transform.parent.GetComponent<SignsController>(); GameObject signPrefab = null; if (currentSign == SignsController.SignType.Triangle) { signPrefab = ((Sign)controller.triangleSign).prefab; signObject = Instantiate (signPrefab) as GameObject; } else if (currentSign == SignsController.SignType.Rectangle) { signPrefab = ((Sign)controller.rectangleSign).prefab; signObject = Instantiate (signPrefab) as GameObject; } else if (currentSign == SignsController.SignType.Barrier) { signPrefab = ((Sign)controller.barrierSign).prefab; signObject = Instantiate (signPrefab) as GameObject; } signObject.transform.parent = sign; signObject.transform.localPosition = new Vector3(0,0,0); signObject.transform.localEulerAngles = new Vector3(0,0,0); signObject.transform.localScale = signPrefab.transform.localScale; }