Created
July 4, 2015 13:29
-
-
Save smallrice45/c39d579ecb10de71a69b to your computer and use it in GitHub Desktop.
委託與監聽範本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class DataManager : MonoBehaviour { | |
public delegate void DataLoaderHandler(); | |
public event DataLoaderHandler onLoaderComplete; | |
void Start(){ | |
DoSomething(); | |
} | |
void DoSomething (){ | |
OnLoaderComplete(); | |
} | |
void OnLoaderComplete (){ | |
if (onLoaderComplete != null){ | |
onLoaderComplete (); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class EventTriggerManager : MonoBehaviour { | |
private DataManager m_DataManager; | |
void Start(){ | |
m_DataManager = GetComponent<DataManager>(); | |
m_DataManager.onLoaderComplete += LoadDataToManager; | |
} | |
// Use this for initialization | |
public void LoadDataToManager () { | |
// DoSomething | |
Debug.Log("LoadDataToManager"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment