void Start() { _IsLeftMoving = _relative.GetComponent <IsLeftMoving>(); _image = gameObject.GetComponent <Image>(); _rotationY = gameObject.transform.rotation.y; Rotation(); }
void SpawnLeftRightMovingObject(GameObject Object, int BorderOfScreen) { _delay = Random.Next(0, 3); int leftRight = Random.Next(0, 2); int borderOfScreen = BorderOfScreen; int yCoord = (int)Random.Next(0 + borderOfScreen, Screen.height - borderOfScreen); var newObject = Instantiate(Object, new Vector3(10, 10, 0), Quaternion.identity) as GameObject; newObject.transform.SetParent(_mainCanvas.transform, false); if (leftRight == 0) { newObject.transform.position = new Vector3(Screen.width + (Screen.width * 0.1f), yCoord, 0); } else { newObject.transform.position = new Vector3(-(Screen.width * 0.1f), yCoord, 0); IsLeftMoving IsLeftMoving = newObject.GetComponent <IsLeftMoving>(); IsLeftMoving.IsLeft = false; } }