コード例 #1
0
        void OnGUI()
        {
            /*
             * GUI label, button 의 폰트 사이즈를 설정.
             * */
#if UNITY_ANDROID || UNITY_IPHONE
            GUI.skin.label.fontSize  = 30;
            GUI.skin.button.fontSize = 30;
#endif

            GUI.Box(new Rect(m_screenWidth / 2 - m_screenOneW * 2, m_screenOneH, m_screenOneW * 4, m_height), "");

            m_scrollHeight = 0;

            // 채팅 내용이 얼마만큼의 길이로 표시가 되어야 하는지 계산.
            foreach (string str in LogList)
            {
                m_scrollHeight = m_scrollHeight + (int)GUI.skin.label.CalcHeight(new GUIContent(str), (float)(m_screenOneW * 4));
            }

            if (m_height > m_scrollHeight)
            {
                m_scrollHeight = m_height;
            }

            // 채팅창 스크롤바.
            m_scrollPosition = GUI.BeginScrollView(new Rect(m_screenWidth / 2 - m_screenOneW * 2, m_screenOneH, m_screenOneW * 4, m_height), m_scrollPosition, new Rect(m_screenWidth / 2 - m_screenOneW * 2, m_screenOneH, m_screenOneW * 4, m_scrollHeight), GUIStyle.none, GUI.skin.verticalScrollbar);

            float h = 0;

            foreach (string str in LogList)
            {
                float labelHeight = 0;
                labelHeight = GUI.skin.label.CalcHeight(new GUIContent(str), (float)(m_screenOneW * 4));
                GUI.Label(new Rect(m_screenWidth / 2 - m_screenOneW * 2, m_screenOneH + h, m_screenOneW * 4, labelHeight), str);
                h = h + labelHeight;
            }

            // 스크롤바가 그려질 영역이 끝낫음을 의미.
            GUI.EndScrollView();

            if (GUI.Button(new Rect(m_screenWidth / 2 - m_screenOneW, m_screenOneH * 8, m_screenOneW, m_screenOneH), "Send"))
            {
                m_simpleProxy.Chat(HostID.HostID_Server, RmiContext.ReliableSend, "메롱.", 22, 22.33f);
            }

            if (GUI.Button(new Rect(m_screenWidth / 2, m_screenOneH * 8, m_screenOneW, m_screenOneH), "P2PSend"))
            {
                if (m_eventSink.GroupID != HostID.HostID_Server)
                {
                    m_simpleProxy.P2PChat(m_eventSink.GroupID, RmiContext.ReliableSend, "Welcome ProudNet!!", 1, 1);
                }
            }

            if (GUI.Button(new Rect(m_screenWidth / 2 + m_screenOneW, m_screenOneH * 8, m_screenOneW, m_screenOneH), "QUIT"))
            {
                Application.Quit();                 // 어플리케이션 종료.
            }
        }
コード例 #2
0
        public void OnP2PMemberJoin(HostID memberHostID, HostID groupHostID, int memberCount, ByteArray customField)
        {
            SimpleApp.print("[Client] P2P member " + memberHostID + " joined  group " + groupHostID + ".");

            this.GroupID = groupHostID;

            if (memberHostID != m_client.LocalHostID)
            {
                m_simpleProxy.P2PChat(memberHostID, RmiContext.ReliableSend, "Hello~~", 1, 1);
            }
        }