protected void SendMessageForSaveDB(Byte[] InSendMessageBuffers) { string LockID = "1234567890ABCDE"; string MessageID = string.Format("{0:X2}", InSendMessageBuffers[9]) + string.Format("{0:X2}", InSendMessageBuffers[8]); string SendMessageString = null; for (int i = 0; i < InSendMessageBuffers.Length; i++) { SendMessageString = SendMessageString + string.Format("{0:X2}", InSendMessageBuffers[i]); } MessageListManager MyMessageListManager = new MessageListManager(); MyMessageListManager.InsertMessageSave(LockID, MessageID, SendMessageString); }
private static void PrintMessage(string list, string message, int?messageTime, Color?messageColor, int?margin, Color?fontColor, int?fontSize, FontStyle?style, TextAnchor?anchor) { try{ if (!messageLists.ContainsKey(list)) { throw new Exception("Cannot Find List: " + list); } MessageListManager mLM = messageLists[list].GetComponent <MessageListManager>(); GameObject newMessage = MonoBehaviour.Instantiate(mLM.messagePrefab) as GameObject; newMessage.GetComponent <Image>().color = messageColor ?? mLM.defaultBackgroundColor; newMessage.GetComponent <MessageTimer>().messageSeconds = messageTime ?? mLM.defaultTime; Text newMessageText = newMessage.GetComponentInChildren <Text>(); newMessageText.text = message; newMessageText.color = fontColor ?? mLM.defaultFontColor; newMessageText.fontSize = fontSize ?? mLM.defaultFontSize; newMessageText.fontStyle = style ?? mLM.defaultFontStyle; newMessageText.alignment = anchor ?? mLM.defaultTextAnchor; newMessage.transform.SetParent(mLM.transform, false); if (mLM.fillFromTopDown) { newMessage.transform.SetAsFirstSibling(); } if (mLM.writeToLogFile) { StackTrace trace = new StackTrace(2, false); streamWriters[list].Write(Time.realtimeSinceStartup + ": " + " Type and Method: " + trace.GetFrame(0).GetMethod() + System.Environment.NewLine + message + System.Environment.NewLine + System.Environment.NewLine); } } catch (Exception ex) { //UnityEngine.Debug.LogError(ex.Message); //UnityEngine.Debug.LogWarning("Could not find the specified message list, printing message to Debug.log instead"); UnityEngine.Debug.Log(message); } }
// this signature lets you configure the font color, size, style and anchor public static void Message(string list, string message, int?messageTime, Color fontColor, int?fontSize, FontStyle fontStyle, TextAnchor textAnchor) { MessageListManager mLM = messageLists[list].GetComponent <MessageListManager>(); PrintMessage(list, message, messageTime, mLM.defaultBackgroundColor, mLM.defaultMargin, fontColor, fontSize, fontStyle, textAnchor); }