Example #1
0
 public void CollectData(GameObject rootGo)
 {
     if (rootGo != null)
     {
         MonoBehaviour[] lstDatas = rootGo.GetComponentsInChildren <MonoBehaviour>();
         foreach (MonoBehaviour m in lstDatas)
         {
             ISaveDataInScene s = m as ISaveDataInScene;
             if (s != null)
             {
                 string strKey = m.gameObject.name + s.GetType().Name;
                 int    key    = strKey.GetHashCode();
                 _datas[key] = s.ExportData();
             }
         }
     }
 }
Example #2
0
 public void DispatchData(GameObject rootGo)
 {
     if (rootGo != null)
     {
         MonoBehaviour[] lstDatas = rootGo.GetComponentsInChildren <MonoBehaviour>();
         foreach (MonoBehaviour m in lstDatas)
         {
             ISaveDataInScene s = m as ISaveDataInScene;
             if (s != null)
             {
                 string strKey = m.gameObject.name + s.GetType().Name;
                 int    key    = strKey.GetHashCode();
                 byte[] buff;
                 if (_datas.TryGetValue(key, out buff))
                 {
                     s.ImportData(buff);
                 }
             }
         }
     }
 }