Skip to content

Instantly share code, notes, and snippets.

@minghanbai
Created July 4, 2015 13:29
Show Gist options
  • Select an option

  • Save minghanbai/c39d579ecb10de71a69b to your computer and use it in GitHub Desktop.

Select an option

Save minghanbai/c39d579ecb10de71a69b to your computer and use it in GitHub Desktop.

Revisions

  1. smallrice45 created this gist Jul 4, 2015.
    21 changes: 21 additions & 0 deletions DataManager
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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 ();
    }
    }
    17 changes: 17 additions & 0 deletions EventTriggerManager
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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");
    }
    }