void Start() { foreach (ExplodingFruit explodingFruit in FindObjectsOfType(typeof(ExplodingFruit))) { DemoFruit demoFruit = explodingFruit.gameObject.AddComponent <DemoFruit>(); demoFruits.Add(demoFruit); demoFruit.gameObject.layer = 9; } }
void Update() { if (Input.GetMouseButton(0)) { DemoFruit fruitUnderCursor = CheckForFruitUnderCursor(); if (fruitUnderCursor != null) { fruitUnderCursor.Tremble(); } } else if (Input.GetMouseButtonUp(0)) { DemoFruit fruitUnderCursor = CheckForFruitUnderCursor(); if (fruitUnderCursor != null) { fruitUnderCursor.Deactivate(); } } }