From 9082a536ce3b041cfc50ee06f22f5ed2c73517ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=92=E8=8D=A3=E6=A3=AE?= <7716842+shurongsen@user.noreply.gitee.com> Date: Thu, 31 Oct 2024 16:50:35 +0800 Subject: [PATCH] add --- .../Resources/preform/gui/Input_box.prefab | 15 +++ .../preform/gui/Input_box_butt.prefab | 15 +++ meng_yao/Assets/Scenes/main_scene.unity | 12 ++ meng_yao/Assets/communal/mount.cs | 5 +- .../Assets/script/ConnactServer/InitInfo.cs | 115 ++++++++++-------- .../Assets/script/ConnactServer/Logo_in.cs | 3 +- meng_yao/Assets/script/Manager/InputUI.cs | 44 +++++++ .../Assets/script/Manager/InputUI.cs.meta | 11 ++ meng_yao/Assets/script/Panel/AssestPanel.cs | 7 +- 9 files changed, 172 insertions(+), 55 deletions(-) create mode 100644 meng_yao/Assets/script/Manager/InputUI.cs create mode 100644 meng_yao/Assets/script/Manager/InputUI.cs.meta diff --git a/meng_yao/Assets/Resources/preform/gui/Input_box.prefab b/meng_yao/Assets/Resources/preform/gui/Input_box.prefab index fd0fc530e..5d2697e82 100644 --- a/meng_yao/Assets/Resources/preform/gui/Input_box.prefab +++ b/meng_yao/Assets/Resources/preform/gui/Input_box.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 3337341073054923217} - component: {fileID: 3337341073054923214} - component: {fileID: 7112672788633924792} + - component: {fileID: 8832094955958116167} m_Layer: 5 m_Name: InputField (Legacy) m_TagString: Untagged @@ -168,6 +169,19 @@ MonoBehaviour: m_FlexibleWidth: 50 m_FlexibleHeight: -1 m_LayoutPriority: 10 +--- !u!114 &8832094955958116167 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3337341073054923212} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b82c0068047f09c499145d4eb8ffb6d9, type: 3} + m_Name: + m_EditorClassIdentifier: + inputField: {fileID: 3337341073054923214} --- !u!1 &3337341073515583678 GameObject: m_ObjectHideFlags: 0 @@ -355,6 +369,7 @@ MonoBehaviour: textobj: {fileID: 3337341074074513327} promptobj: {fileID: 3337341073515583678} contentobj: {fileID: 3337341074177666619} + iconobj: {fileID: 0} --- !u!1 &3337341074074513327 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/Resources/preform/gui/Input_box_butt.prefab b/meng_yao/Assets/Resources/preform/gui/Input_box_butt.prefab index 99332e6d7..0c2d6d281 100644 --- a/meng_yao/Assets/Resources/preform/gui/Input_box_butt.prefab +++ b/meng_yao/Assets/Resources/preform/gui/Input_box_butt.prefab @@ -204,6 +204,7 @@ MonoBehaviour: textobj: {fileID: 4246764786122325446} promptobj: {fileID: 4246764787755305687} contentobj: {fileID: 4246764786287869010} + iconobj: {fileID: 0} --- !u!1 &4246764786122325446 GameObject: m_ObjectHideFlags: 0 @@ -398,6 +399,7 @@ GameObject: - component: {fileID: 4246764787410611128} - component: {fileID: 4246764787410611111} - component: {fileID: 7335891663269242643} + - component: {fileID: 8724552994600978160} m_Layer: 5 m_Name: InputField (Legacy) m_TagString: Untagged @@ -553,6 +555,19 @@ MonoBehaviour: m_FlexibleWidth: 10 m_FlexibleHeight: -1 m_LayoutPriority: 1 +--- !u!114 &8724552994600978160 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4246764787410611109} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b82c0068047f09c499145d4eb8ffb6d9, type: 3} + m_Name: + m_EditorClassIdentifier: + inputField: {fileID: 4246764787410611111} --- !u!1 &4246764787755305687 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/Scenes/main_scene.unity b/meng_yao/Assets/Scenes/main_scene.unity index 2200ebb02..dcb9e4a2d 100644 --- a/meng_yao/Assets/Scenes/main_scene.unity +++ b/meng_yao/Assets/Scenes/main_scene.unity @@ -306,6 +306,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b0d037404676f94408d73bb6199200aa, type: 3} m_Name: m_EditorClassIdentifier: + username: {fileID: 3011360594389648156} --- !u!1 &304400296 GameObject: m_ObjectHideFlags: 0 @@ -1796,3 +1797,14 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3} +--- !u!114 &3011360594389648156 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 3011360592512948003, guid: a8cc81ed2c5736a46a14628d8d489ac4, type: 3} + m_PrefabInstance: {fileID: 3011360594389648155} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/meng_yao/Assets/communal/mount.cs b/meng_yao/Assets/communal/mount.cs index f98c06f9e..44c81a7e7 100644 --- a/meng_yao/Assets/communal/mount.cs +++ b/meng_yao/Assets/communal/mount.cs @@ -21,7 +21,10 @@ public struct Login public string Phone; } - +public struct GetListByPhone +{ + public string Phone; +} diff --git a/meng_yao/Assets/script/ConnactServer/InitInfo.cs b/meng_yao/Assets/script/ConnactServer/InitInfo.cs index b7cab8a00..fa50d9dba 100644 --- a/meng_yao/Assets/script/ConnactServer/InitInfo.cs +++ b/meng_yao/Assets/script/ConnactServer/InitInfo.cs @@ -1,72 +1,85 @@ +using System; using System.Collections; using System.Collections.Generic; +using UnityEditor.Hardware; +using UnityEditorInternal.VersionControl; using UnityEngine; +using UnityEngine.UI; public class InitInfo : MonoBehaviour { + private MainObject parsedData; + private Username userdata; + public Text name; // Start is called before the first frame update - private async void Start() + private async void Start() { - string response = await web.SendRequest("http://47.109.133.52/Item/GetList", "POST"); + string response = await web.SendRequest("http://47.109.133.52/Player/GetInfo", "POST"); Debug.Log(response); + + parsedData = JsonUtility.FromJson(response); + + Debug.Log(parsedData.Info.Gold); + + AssestPanel.instance.SetCoinText(parsedData.Info.Gold); + AssestPanel.instance.SetStoneText(parsedData.Info.Gem); + + + GetListByPhone getlistbyphone = new GetListByPhone(); + getlistbyphone.Phone = "1"; + string jsonString = JsonUtility.ToJson(getlistbyphone); + string userponse = await web.SendRequest("http://47.109.133.52/Player/GetListByPhone", "POST", jsonString); + Debug.Log(userponse); + userdata = JsonUtility.FromJson(userponse); + Debug.Log(userdata.ErrorCode); + + //name.text=userdata.nameitem.Name; } // Update is called once per frame void Update() { - + } + } - -/// -/// 获取所有商品数据 -/// - -public class LevelUpNeedItem +public class MainObject { - public int Num; - public int Count; -} - - -public class LevelUpNeedThing -{ - public int Gold; - public List Items; -} - - -public class Character -{ - public int Num; // 角色编号 - public string Name; // 角色名称 - public float Hp; // 生命值 - public float HpUpMul; // 生命值成长倍率 - public float Attack; // 攻击力 - public float AttackUpMul; // 攻击力成长倍率 - public float Defense; // 防御力 - public float DefenseUpMul; // 防御力成长倍率 - public float AttackSpeed; // 攻击速度 - public float AttackSpeedUpMul; // 攻击速度成长倍率 - public float Move; // 移动速度 - public float MoveUpMul; // 移动速度成长倍率 - public List Skill; // 技能ID列表 - public int Attribute; // 角色属性 - public string LevelUpNeedThingsJson; // 升级所需物品的JSON字符串 - public string Expand; // 扩展字段(用于未来扩展或附加数据) - public int Type; // 角色类型 - public int Rarity; // 角色稀有度 - public string WeaponBulletEffectPath; // 武器子弹效果路径 - public string WeaponBulletHitEffectPath; // 武器子弹命中效果路径 - public int UltimateSkill; // 终极技能ID - public int Access; // 获取途径或可用性 - public List SellDate; // 售卖日期列表(如果适用) -} - -public class CharacterListResponse -{ - public List List; + public Info Info; public int ErrorCode; public string ErrorMessage; } + +[Serializable] +public class Info +{ + public string Id; + public int Gold; + public int Gem; + + public string Phone; + public string Name; +} + + +public class Username +{ + public List namelist; + public int ErrorCode; + public string ErrorMessage; +} + +public class nameitem +{ + public string Id; + public string Phone; + public string Name; +} + + + + + + + diff --git a/meng_yao/Assets/script/ConnactServer/Logo_in.cs b/meng_yao/Assets/script/ConnactServer/Logo_in.cs index 2b1b8b1be..b1bceaa5a 100644 --- a/meng_yao/Assets/script/ConnactServer/Logo_in.cs +++ b/meng_yao/Assets/script/ConnactServer/Logo_in.cs @@ -84,7 +84,7 @@ public class Logo_in : mount - if (root.ErrorMessage=="") + if (root.ErrorMessage=="" && boxTypes[0].content!= "") { gameObject.SetActive(false); Promptmgr.Instance.PromptBubble("登录成功"); @@ -122,7 +122,6 @@ public class Logo_in : mount { // 这里使用场景管理器进行跳转 SceneManager.LoadScene(JumpScene.main_scene); - } diff --git a/meng_yao/Assets/script/Manager/InputUI.cs b/meng_yao/Assets/script/Manager/InputUI.cs new file mode 100644 index 000000000..0c651edad --- /dev/null +++ b/meng_yao/Assets/script/Manager/InputUI.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + + +public class InputUI : MonoBehaviour +{ + public InputField inputField; + + private void Start() + { + EventTrigger trigger = inputField.gameObject.AddComponent(); + + // 添加点击事件 + EventTrigger.Entry clickEntry = new EventTrigger.Entry(); + clickEntry.eventID = EventTriggerType.PointerClick; + clickEntry.callback.AddListener((data) => { HidePlaceholder(); }); + trigger.triggers.Add(clickEntry); + + // 添加鼠标离开事件 + EventTrigger.Entry exitEntry = new EventTrigger.Entry(); + exitEntry.eventID = EventTriggerType.PointerExit; + exitEntry.callback.AddListener((data) => { ShowPlaceholder(); }); + trigger.triggers.Add(exitEntry); + } + + private void HidePlaceholder() + { + if (inputField.placeholder != null) + { + inputField.placeholder.gameObject.SetActive(false); + } + } + + private void ShowPlaceholder() + { + if (inputField.placeholder != null && string.IsNullOrEmpty(inputField.text)) + { + inputField.placeholder.gameObject.SetActive(true); + } + } +} diff --git a/meng_yao/Assets/script/Manager/InputUI.cs.meta b/meng_yao/Assets/script/Manager/InputUI.cs.meta new file mode 100644 index 000000000..9d76f2023 --- /dev/null +++ b/meng_yao/Assets/script/Manager/InputUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b82c0068047f09c499145d4eb8ffb6d9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/meng_yao/Assets/script/Panel/AssestPanel.cs b/meng_yao/Assets/script/Panel/AssestPanel.cs index d246e27d2..110cc88ad 100644 --- a/meng_yao/Assets/script/Panel/AssestPanel.cs +++ b/meng_yao/Assets/script/Panel/AssestPanel.cs @@ -10,7 +10,8 @@ public class AssestPanel : MonoBehaviour public Text Coin; public Text Ore; public Text Forging; - + + void Start() { instance = this; @@ -18,6 +19,8 @@ public class AssestPanel : MonoBehaviour Forging.text=PlayerManager.Instance.Forging.ToString(); Coin.text=PlayerManager.Instance.Coins.ToString(); Ore.text=PlayerManager.Instance.Ore.ToString(); + + } public void SetStoneText(float num) @@ -49,4 +52,6 @@ public class AssestPanel : MonoBehaviour Forging.text = num.ToString(); } } + + }