public static void Send(string message, object value) { lock (typeof(Messenger)) { if (CanBeUsed(null, message)) { if (s_instance.m_registeredGameObjects.ContainsKey(message)) { List <GameObject> gos = s_instance.m_registeredGameObjects [message]; int length = gos.Count; //SHLog.Debug("[Messenger] Enviando a mensagem '" + message + "' para '" + length + "' GameObjects registrados."); for (int i = 0; i < length; i++) { try { //SHLog.Debug("[Messenger] - " + gos[i].name); gos [i].SendMessage(message, value, SendMessageOptions.DontRequireReceiver); } catch (MissingReferenceException ex) { SHLog.Error("[Messenger] Error while sending message '{0}': {1}.", message, ex.Message); } } } else { SHLog.Warning("[Messenger] The message '{0}' has no receivers.", message); } } } }
/// <summary> /// Validates the state. /// </summary> private static void ValidateState() { if (s_instance == null) { SHLog.Error("SHGameInfo can't be used before the script be inserted on a game object in the first loaded scene."); } }
public static TTarget DeserializeFromBytes <TTarget> (byte[] targetBytes) { try { var formatter = new BinaryFormatter(); using (var stream = new MemoryStream(targetBytes)) { return((TTarget)formatter.Deserialize(stream)); } } catch (System.Exception ex) { SHLog.Error(ex.Message); return(default(TTarget)); } }
/// <summary> /// Gets the game object from the pool. /// </summary> /// <returns> /// The game object. /// </returns> /// <param name='position'> /// Position. /// </param> public GameObject GetGameObject(Vector3 position) { int length = m_gameObjects.Count; GameObject go = null; for (int i = 0; i < length; i++) { go = m_gameObjects[i]; if (go == null) { SHLog.Error("Pool: {0} - GameObject on index {1} is null. You should not call Destroy() in objects that are in a pool.", Name, i); } if (IsObjectEnabled(go)) { go = null; } else { break; } } if (go == null) { if (IsSizeFixed) { go = m_gameObjects[0]; m_gameObjects.RemoveAt(0); m_gameObjects.Add(go); } else { go = AddGameObject(); } } EnableGameObject(go, position); return(go); }