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); } } } }
private void Awake() { SHLog.Debug("SHGameObjectsQualityController: initializing quality objects selection..."); Instance = this; if (IsCurrentDeviceBestQuality) { SHLog.Debug("SHGameObjectsQualityController: current device is a best quality device. Removing good and normal qualities game objects."); SHGameObjectHelper.Destroy(GoodQualityGameObjects); SHGameObjectHelper.Destroy(NormalQualityGameObjects); } else if (IsCurrentDeviceGoodQuality) { SHLog.Debug("SHGameObjectsQualityController: current device is a good quality device. Removing best and normal qualities game objects."); SHGameObjectHelper.Destroy(BestQualityGameObjects); SHGameObjectHelper.Destroy(NormalQualityGameObjects); } else { SHLog.Debug("SHGameObjectsQualityController: current device is a normal quality device. Removing best and good qualities game objects."); SHGameObjectHelper.Destroy(BestQualityGameObjects); SHGameObjectHelper.Destroy(GoodQualityGameObjects); } }
private IEnumerator Request(SHKeyValue keyValue, string methodName, Action <string> valueReceived = null) { var url = string.Format(CultureInfo.InvariantCulture, "{0}/services/storage/{1}.ashx?playerId={2}&key={3}&value={4}", m_serverAddress, methodName, m_playerId, keyValue.Key, keyValue.Value); SHLog.Debug("SHGlobalServerKeyValueStorageProvider: requesting url '{0}'.", url); var www = new WWW(url); yield return(www); if (String.IsNullOrEmpty(www.error)) { var response = www.text; if (!String.IsNullOrEmpty(response)) { SHLog.Debug("SHGlobalServerKeyValueStorageProvider: response received '{0}'.", response); if (valueReceived != null) { valueReceived(response.Replace("\"", "")); } } } else { SettingValueFailed.Raise(this, new SHSettingValueFailedEventArgs(keyValue)); } }
void Update() { if (Input.touchCount >= 3) { StringBuilder log = new StringBuilder(); log.AppendLine("================================="); log.AppendLine("Skahal Studios Leak Finder Script"); log.AppendLine("=========LOADED OBJECTS=========="); log.AppendLine("All " + Resources.FindObjectsOfTypeAll(typeof(UnityEngine.Object)).Length); log.AppendLine("Textures " + Resources.FindObjectsOfTypeAll(typeof(Texture)).Length); log.AppendLine("AudioClips " + Resources.FindObjectsOfTypeAll(typeof(AudioClip)).Length); log.AppendLine("Meshes " + Resources.FindObjectsOfTypeAll(typeof(Mesh)).Length); log.AppendLine("Materials " + Resources.FindObjectsOfTypeAll(typeof(Material)).Length); log.AppendLine("GameObjects " + Resources.FindObjectsOfTypeAll(typeof(GameObject)).Length); log.AppendLine("Components " + Resources.FindObjectsOfTypeAll(typeof(Component)).Length); log.AppendLine("=========ACTIVE OBJECTS=========="); log.AppendLine("================================="); log.AppendLine("All " + GameObject.FindObjectsOfType(typeof(UnityEngine.Object)).Length); log.AppendLine("Textures " + GameObject.FindObjectsOfType(typeof(Texture)).Length); log.AppendLine("AudioClips " + GameObject.FindObjectsOfType(typeof(AudioClip)).Length); log.AppendLine("Meshes " + GameObject.FindObjectsOfType(typeof(Mesh)).Length); log.AppendLine("Materials " + GameObject.FindObjectsOfType(typeof(Material)).Length); log.AppendLine("GameObjects " + GameObject.FindObjectsOfType(typeof(GameObject)).Length); log.AppendLine("Components " + GameObject.FindObjectsOfType(typeof(Component)).Length); SHLog.Debug(log.ToString()); } }
/// <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 virtual void Modify(TEntity entity) { var serialized = SHSerializer.SerializeToString(entity); var key = GetKey(entity.Id); SHLog.Debug("Serializing key '{0}' with raw value: '{1}'", key, serialized); PlayerPrefs.SetString(key, serialized); }
public string[] GetAllIds() { var ids = PlayerPrefs.GetString(GetAllIdsKey(), ""); SHLog.Debug("Ids '{0}' found on {1}.", ids, GetType().Name); return(ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Where(id => !String.IsNullOrEmpty(id.Trim())) .ToArray()); }
void StartNight() { SHLog.Debug("DayNightControllerScript.StartNight"); IsDay = false; RenderSettings.skybox = NightSkybox; RenderSettings.ambientLight = NightAmbientLight; SHGameObjectHelper.Deactive(DayGameObjects, true); SHGameObjectHelper.Active(NightGameObjects, true); Messenger.Send("OnNightStarted"); }
void StartDay() { SHLog.Debug("DayNightControllerScript.StartDay"); IsDay = true; RenderSettings.skybox = DaySkybox; RenderSettings.ambientLight = DayAmbientLight; SHGameObjectHelper.Deactive(NightGameObjects, true); SHGameObjectHelper.Active(DayGameObjects, true); Messenger.Send("OnDayStarted"); }
private void Awake() { DontDestroyOnLoad(this); s_settings = Settings.ToDictionary(); SHLog.Debug("SHConfigManager: {0} settings available.", s_settings.Count); foreach (var s in s_settings) { SHLog.Debug("\t{0} = {1}", s.Key, s.Value); } }
private void OnLevelWasLoaded() { foreach (var msg in m_registeredGameObjects) { var removedCount = msg.Value.RemoveAll( (go) => { return(go == null); }); if (removedCount > 0) { SHLog.Debug("[Messenger] {0} GameObjects was removed from message '{1}'. {2} GameObjects remaining.", removedCount, msg.Key, msg.Value.Count); } } }
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)); } }
private static bool CanBeUsed(GameObject go, string message) { var can = s_instance != null; if (!can) { if (go == null) { SHLog.Warning("[Messenger] Attempt to send the message '{0}' without the Messenger script has been add to a GameObject.", message); } else { SHLog.Warning("[Messenger] The GameObject '{0}' has attempt to register message without the Messenger script has been add to a GameObject.", go.name); } } return(can); }
/// <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); }
/// <summary> /// Takes the screenshot from screen. /// </summary> public static void TakeScreenshot(Action <string> screenshotTakenCallback) { var fileName = Path.Combine(Application.persistentDataPath, "SHScreenshotHelper_TakeScreenshot.png"); SHFileHelper.DeleteIfExists(fileName); ScreenCapture.CaptureScreenshot(fileName); SHLog.Debug("SHScreenshotHelper.TakeScreenshot: {0}", fileName); SHCoroutine.WaitFor( () => { return(File.Exists(fileName)); }, () => { screenshotTakenCallback(fileName); } ); }
public static GameObject GetNearestFrom(GameObject from, IEnumerable <GameObject> others) { SHLog.Debug("GetNearestFrom: from = " + from.name); GameObject nearest = null; float lowestDistance = float.MaxValue; foreach (GameObject go in others) { SHLog.Debug("GetNearestFrom: go = " + go.name); if (go.GetInstanceID() != from.GetInstanceID()) { float d = Vector3.Distance(go.transform.position, from.transform.position); if (d < lowestDistance) { lowestDistance = d; nearest = go; } } } return(nearest); }
/// <summary> /// Clear the memory. /// </summary> public static void Clear() { SHLog.Debug("SHMemoryCleaner: memory in use before cleaning: {0}", GC.GetTotalMemory(false)); Resources.UnloadUnusedAssets(); SHLog.Debug("SHMemoryCleaner: memory in use after cleaning: {0}", GC.GetTotalMemory(true)); }