// In development - not used! private void ReplaceMessage(ChirpMessage delMessage, ChirpMessage replaceMessage) { // Get container for chirps Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform; for (int i = 0; i < container.childCount; ++i) { if (container.GetChild(i).GetComponentInChildren <UILabel>().text.Equals(delMessage.GetText())) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Replaced Message:" + delMessage.text); // Remove both visual and internal message. UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent <UIPanel>()); chirpPane.AddMessage(replaceMessage, true); // Find the original message, replace it in manager. MessageBase[] messages = (MessageBase[])typeof(MessageManager).GetField("m_recentMessages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(MessageManager.instance); for (int j = 0; j < messages.Length; ++j) { if (messages[i].text.Equals(delMessage)) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] New Message:" + delMessage.text); messages[i] = replaceMessage; } } //DEBUGGING MessageBase[] finalMessages = (MessageBase[])typeof(MessageManager).GetField("m_recentMessages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(MessageManager.instance); foreach (MessageBase message in finalMessages) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Final Message:" + message.text); } return; } } }
// Custom method to delete a single message - uses ChirpMessages. private void DeleteMessage(ChirpMessage message) { // Get container for chirps Transform container = chirpPane.transform.FindChild("Chirps").FindChild("Clipper").FindChild("Container").gameObject.transform; for (int i = 0; i < container.childCount; ++i) { if (container.GetChild(i).GetComponentInChildren <UILabel>().text.Equals(message.GetText())) { DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] Deleted Message:" + message.text); // Remove both visual and internal message. UITemplateManager.RemoveInstance("ChirpTemplate", container.GetChild(i).GetComponent <UIPanel>()); // Find the original message, remove it from manager. IChirperMessage delMessage; messageMap.TryGetValue(message, out delMessage); messageManager.DeleteMessage(delMessage); if (!userOpened) { chirpPane.Collapse(); } return; } } }