void InitComponents() { uiPanel = GameObject.Find ("JIVERUI/UIPanel"); (Instantiate (uiThemePrefab) as GameObject).transform.parent = uiPanel.transform; uiTheme = GameObject.FindObjectOfType (typeof(JiverTheme)) as JiverTheme; mainPanel = GameObject.Find ("JIVERUI/UIPanel/MainPanel"); mainPanel.GetComponent<Image> ().sprite = uiTheme.chatFrameBG; channelPanel = GameObject.Find ("JIVERUI/UIPanel/ChannelPanel"); channelPanel.GetComponent<Image> ().sprite = uiTheme.channelListFrameBG; gridPannel = GameObject.Find ("JIVERUI/UIPanel/ChannelPanel/ScrollArea/GridPanel"); txtContent = GameObject.Find("JIVERUI/UIPanel/MainPanel/ScrollArea/TxtContent").GetComponent<Text>();// (Text); txtContent.color = uiTheme.messageColor; txtTitle = GameObject.Find ("JIVERUI/UIPanel/MainPanel/TxtTitle").GetComponent<Text> (); txtTitle.color = uiTheme.titleColor; scrollbar = GameObject.Find ("JIVERUI/UIPanel/MainPanel/Scrollbar").GetComponent<Scrollbar>(); ColorBlock cb = scrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; scrollbar.colors = cb; scrollbar.onValueChanged.AddListener ((float value) => { if(value <= 0) { autoScroll = true; lastTextPositionY = txtContent.transform.position.y; return; } if(lastTextPositionY - txtContent.transform.position.y >= 100) { autoScroll = false; } lastTextPositionY = txtContent.transform.position.y; }); inputMessage = GameObject.Find ("JIVERUI/UIPanel/MainPanel/InputMessage").GetComponent<InputField> (); inputMessage.GetComponent<Image> ().sprite = uiTheme.inputTextBG; inputMessage.onEndEdit.AddListener ((string msg) => { Submit(); }); GameObject.Find ("JIVERUI/UIPanel/MainPanel/InputMessage/Placeholder").GetComponent<Text> ().color = uiTheme.inputTextPlaceholderColor; GameObject.Find ("JIVERUI/UIPanel/MainPanel/InputMessage/Text").GetComponent<Text> ().color = uiTheme.inputTextColor; btnSend = GameObject.Find ("JIVERUI/UIPanel/MainPanel/BtnSend").GetComponent<Button> (); btnSend.GetComponent<Image> ().sprite = uiTheme.sendButton; btnSend.GetComponentInChildren<Text> ().color = uiTheme.sendButtonColor; btnSend.onClick.AddListener (() => { Submit(); }); btnClan = GameObject.Find ("JIVERUI/UIPanel/MainPanel/BtnClan").GetComponent<Button> (); btnClan.GetComponent<Image> ().sprite = uiTheme.chatChannelButtonOff; btnClan.onClick.AddListener (() => { Connect ("jia_test.Clan"); SelectTab(TAB_MODE.CLAN); }); btnMainClose = GameObject.Find ("JIVERUI/UIPanel/MainPanel/BtnClose").GetComponent<Button> (); btnMainClose.GetComponent<Image> ().sprite = uiTheme.closeButton; btnMainClose.onClick.AddListener (() => { uiPanel.SetActive(false); }); GameObject.Find ("JIVERUI/UIPanel/ChannelPanel/TxtTitle").GetComponent<Text> ().color = uiTheme.titleColor; Scrollbar channelScrollbar = GameObject.Find ("JIVERUI/UIPanel/ChannelPanel/Scrollbar").GetComponent<Scrollbar>(); cb = channelScrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; channelScrollbar.colors = cb; btnChannel = GameObject.Find ("JIVERUI/UIPanel/MainPanel/BtnChannel").GetComponent<Button> (); btnChannel.GetComponent<Image> ().sprite = uiTheme.chatChannelButtonOff; btnChannel.onClick.AddListener (() => { OpenChannelList(); }); btnChannelClose = GameObject.Find ("JIVERUI/UIPanel/ChannelPanel/BtnChannelClose").GetComponent<Button> (); btnChannelClose.GetComponent<Image> ().sprite = uiTheme.closeButton; btnChannelClose.onClick.AddListener (() => { channelPanel.SetActive(false); }); uiPanel.SetActive (true); mainPanel.SetActive (true); channelPanel.SetActive (false); }
string MessageRichText(Message message) { return("<color=#" + JiverTheme.ToHex(uiTheme.senderColor) + ">" + message.GetSenderName() + ": </color>" + message.GetMessage()); }
string SystemMessageRichText(string message) { return("<color=#" + JiverTheme.ToHex(uiTheme.systemMessageColor) + ">" + message + "</color>"); }
void InitComponents() { uiPanel = GameObject.Find("JIVERUI/UIPanel"); (Instantiate(uiThemePrefab) as GameObject).transform.parent = uiPanel.transform; uiTheme = GameObject.FindObjectOfType(typeof(JiverTheme)) as JiverTheme; mainPanel = GameObject.Find("JIVERUI/UIPanel/MainPanel"); mainPanel.GetComponent <Image> ().sprite = uiTheme.chatFrameBG; channelPanel = GameObject.Find("JIVERUI/UIPanel/ChannelPanel"); channelPanel.GetComponent <Image> ().sprite = uiTheme.channelListFrameBG; gridPannel = GameObject.Find("JIVERUI/UIPanel/ChannelPanel/ScrollArea/GridPanel"); txtContent = GameObject.Find("JIVERUI/UIPanel/MainPanel/ScrollArea/TxtContent").GetComponent <Text>(); // (Text); txtContent.color = uiTheme.messageColor; txtTitle = GameObject.Find("JIVERUI/UIPanel/MainPanel/TxtTitle").GetComponent <Text> (); txtTitle.color = uiTheme.titleColor; scrollbar = GameObject.Find("JIVERUI/UIPanel/MainPanel/Scrollbar").GetComponent <Scrollbar>(); ColorBlock cb = scrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; scrollbar.colors = cb; scrollbar.onValueChanged.AddListener((float value) => { if (value <= 0) { autoScroll = true; lastTextPositionY = txtContent.transform.position.y; return; } if (lastTextPositionY - txtContent.transform.position.y >= 100) { autoScroll = false; } lastTextPositionY = txtContent.transform.position.y; }); inputMessage = GameObject.Find("JIVERUI/UIPanel/MainPanel/InputMessage").GetComponent <InputField> (); inputMessage.GetComponent <Image> ().sprite = uiTheme.inputTextBG; inputMessage.onEndEdit.AddListener((string msg) => { Submit(); }); GameObject.Find("JIVERUI/UIPanel/MainPanel/InputMessage/Placeholder").GetComponent <Text> ().color = uiTheme.inputTextPlaceholderColor; GameObject.Find("JIVERUI/UIPanel/MainPanel/InputMessage/Text").GetComponent <Text> ().color = uiTheme.inputTextColor; btnSend = GameObject.Find("JIVERUI/UIPanel/MainPanel/BtnSend").GetComponent <Button> (); btnSend.GetComponent <Image> ().sprite = uiTheme.sendButton; btnSend.GetComponentInChildren <Text> ().color = uiTheme.sendButtonColor; btnSend.onClick.AddListener(() => { Submit(); }); btnClan = GameObject.Find("JIVERUI/UIPanel/MainPanel/BtnClan").GetComponent <Button> (); btnClan.GetComponent <Image> ().sprite = uiTheme.chatChannelButtonOff; btnClan.onClick.AddListener(() => { Connect("jia_test.Clan"); SelectTab(TAB_MODE.CLAN); }); btnMainClose = GameObject.Find("JIVERUI/UIPanel/MainPanel/BtnClose").GetComponent <Button> (); btnMainClose.GetComponent <Image> ().sprite = uiTheme.closeButton; btnMainClose.onClick.AddListener(() => { uiPanel.SetActive(false); }); GameObject.Find("JIVERUI/UIPanel/ChannelPanel/TxtTitle").GetComponent <Text> ().color = uiTheme.titleColor; Scrollbar channelScrollbar = GameObject.Find("JIVERUI/UIPanel/ChannelPanel/Scrollbar").GetComponent <Scrollbar>(); cb = channelScrollbar.colors; cb.normalColor = uiTheme.scrollBarColor; cb.pressedColor = uiTheme.scrollBarColor; cb.highlightedColor = uiTheme.scrollBarColor; channelScrollbar.colors = cb; btnChannel = GameObject.Find("JIVERUI/UIPanel/MainPanel/BtnChannel").GetComponent <Button> (); btnChannel.GetComponent <Image> ().sprite = uiTheme.chatChannelButtonOff; btnChannel.onClick.AddListener(() => { OpenChannelList(); }); btnChannelClose = GameObject.Find("JIVERUI/UIPanel/ChannelPanel/BtnChannelClose").GetComponent <Button> (); btnChannelClose.GetComponent <Image> ().sprite = uiTheme.closeButton; btnChannelClose.onClick.AddListener(() => { channelPanel.SetActive(false); }); uiPanel.SetActive(true); mainPanel.SetActive(true); channelPanel.SetActive(false); }