You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			100 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			100 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C#
		
	
| using UnityEngine;
 | |
| using Game.Common;
 | |
| 
 | |
| 
 | |
| namespace Game
 | |
| {
 | |
|     public class PagePlayerTouch : UIPageBase<ViewPlayerTouch>
 | |
|     {
 | |
|         private int _mCosoleNumMax = 20;
 | |
|         public PagePlayerTouch()
 | |
|         {
 | |
|         }
 | |
|         protected override void OnCreate()
 | |
|         {
 | |
|             CreateUI(false);
 | |
|             View.m_ConsoleInput.onClick.Add(() =>
 | |
|             {
 | |
|                 View.m_ConsoleInput.RequestFocus();
 | |
|             });
 | |
|             SetCosoleVisible(false);
 | |
|         }
 | |
|         protected override void OnDestroy() { }
 | |
|         protected override void OnOpen()
 | |
|         {
 | |
|             View.m_Console.RemoveChildrenToPool();
 | |
|         }
 | |
|         protected override void OnClose()
 | |
|         {
 | |
|         }
 | |
|         public override void Update()
 | |
|         {
 | |
|             var posScreen = Input.mousePosition;
 | |
|             posScreen.y = Screen.height - posScreen.y;
 | |
|             View.m_Cursor.SetPosition(posScreen.x, posScreen.y, posScreen.z);
 | |
|         }
 | |
|         protected override void OnInput(PPlayerInput context)
 | |
|         {
 | |
|             if (context.Action == EKeyActionType.Press)
 | |
|             {
 | |
|                 if (View.m_ConsolePanel.visible)
 | |
|                 {
 | |
|                     if (context.Key == EFunctionKey.Menu)
 | |
|                     {
 | |
|                         View.m_ConsoleInput.text = "";
 | |
|                         SetCosoleVisible(false);
 | |
|                     }
 | |
|                     if (context.Key == EFunctionKey.Enter)
 | |
|                     {
 | |
|                         if (View.m_ConsoleInput.focused)
 | |
|                         {
 | |
|                             OnCosoleSubmit();
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             View.m_ConsoleInput.RequestFocus();
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     if (context.Key == EFunctionKey.Enter)
 | |
|                     {
 | |
|                         SetCosoleVisible(true);
 | |
|                         View.m_ConsoleInput.RequestFocus();
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         private void OnCosoleSubmit()
 | |
|         {
 | |
|             var str = View.m_ConsoleInput.text;
 | |
|             str = str.Replace("\n", "");
 | |
|             if (str.Length == 0)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             View.m_ConsoleInput.text = "";
 | |
|             var consoleInfo = View.m_Console.AddItemFromPool();
 | |
|             consoleInfo.asCom.GetChild("Text").text = str;
 | |
|             while (View.m_Console.numItems > _mCosoleNumMax)
 | |
|             {
 | |
|                 View.m_Console.RemoveChildToPoolAt(0);
 | |
|             }
 | |
|             View.m_Console.ScrollToView(View.m_Console.numItems - 1);
 | |
|         }
 | |
|         private void SetCosoleVisible(bool visible)
 | |
|         {
 | |
|             View.m_ConsolePanel.visible = visible;
 | |
|             if (View.m_ConsolePanel.visible)
 | |
|             {
 | |
|                 UIManager.Instance.Open(EuiPage.GmPanel);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 UIManager.Instance.Close(EuiPage.GmPanel);
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| } |