// Use this for initialization private void Awake() { actions = new Dictionary <String, Action> { { "Tap", delegate { Tap(); } }, }; foreach (KeyValuePair <String, Action> item in actions) { ActionEvent actionEvent = gameObject.AddComponent <ActionEvent>() as ActionEvent; actionEvent.Init(item.Key, item.Value); } //InfoWindow.gameObject.SetActive(false); }
private void Awake() { // Mayve make the following code a static method of ActionEvent // and just pass the dictionary actions = new Dictionary <String, Action> { { "Drag", delegate { StartCoroutine(FollowDrag()); } }, { "Zoom", delegate { StartCoroutine(Zoom()); } } }; foreach (KeyValuePair <String, Action> item in actions) { ActionEvent actionEvent = gameObject.AddComponent <ActionEvent>() as ActionEvent; actionEvent.Init(item.Key, item.Value); } }