Merge branch 'YKing'
# Conflicts: # EintooAR/Assets/AssetRaw/Fonts/优设标题黑 SDF.asset resolved by main version # EintooAR/UserSettings/Layouts/default-6000.dwlt resolved by main version
This commit is contained in:
commit
a51e633949
31
EintooAR/Assets/AssetRaw/UI/YL/Tmp/ARGameData.asset
Normal file
31
EintooAR/Assets/AssetRaw/UI/YL/Tmp/ARGameData.asset
Normal file
@ -0,0 +1,31 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 56f47294b303de74c913b32dfeabd80d, type: 3}
|
||||
m_Name: ARGameData
|
||||
m_EditorClassIdentifier:
|
||||
responseData:
|
||||
data:
|
||||
- GameName: "\u8D2A\u5403\u86C7"
|
||||
GameImgURL: https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1
|
||||
Lock: 0
|
||||
- GameName: "\u6D88\u6D88\u4E50"
|
||||
GameImgURL: https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1
|
||||
Lock: 1
|
||||
- GameName: "\u5438\u5C18\u5668"
|
||||
GameImgURL: https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1
|
||||
Lock: 1
|
||||
- GameName: "\u70DF\u82B1"
|
||||
GameImgURL: https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1
|
||||
Lock: 1
|
||||
- GameName: "AR\u5BFB\u5B9D"
|
||||
GameImgURL: https://arp3.arsnowslide.com/0cc96a251c44408b9c54cec443483d33.jpg?versionId=G00111959395337FFFFF981700E681A1
|
||||
Lock: 1
|
8
EintooAR/Assets/AssetRaw/UI/YL/Tmp/ARGameData.asset.meta
Normal file
8
EintooAR/Assets/AssetRaw/UI/YL/Tmp/ARGameData.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a24f8abaf39cbbd48bdc07ddfab5b465
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
EintooAR/Assets/AssetRaw/UI/YL/UIARGameWindow.meta
Normal file
8
EintooAR/Assets/AssetRaw/UI/YL/UIARGameWindow.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c52136363902cd14d8fcf769bf8839a7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ccfec3427a9cf8c41a180213f342869b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 370c7d806d28a0348ac94ea8dbb49cf1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1697
EintooAR/Assets/AssetRaw/UI/YL/UIARGameWindow/UIARGameWindow.prefab
Normal file
1697
EintooAR/Assets/AssetRaw/UI/YL/UIARGameWindow/UIARGameWindow.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 766c2bf93200be247ad8e72de7016f2e
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -257,9 +257,9 @@ MonoBehaviour:
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "\u786E\u8BA4"
|
||||
- "\u786E\u5B9A"
|
||||
- Sure
|
||||
- "\u78BA\u8A8D"
|
||||
- "\u78BA\u5B9A"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_Tips
|
||||
@ -379,6 +379,34 @@ MonoBehaviour:
|
||||
- "AR\u8B58\u5225"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_ArGameTips
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "\u524D\u5F80\u4F01\u4E1A\u540E\u53F0\u914D\u7F6E\u4E0A\u67B6\u540E\u5373\u53EF\u70B9\u4EAE\u5BF9\u5E94\u6E38\u620F"
|
||||
- G to the enterprise background configuration and put it on the shelof, and
|
||||
you can light up the corresponding game
|
||||
- "\u524D\u5F80\u4F01\u696D\u5F8C\u81FA\u914D\u7F6E\u4E0A\u67B6\u5F8C\u5373\u53EF\u9EDE\u4EAE\u5C0D\u61C9\u904A\u6232"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_ARGame
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "AR\u6E38\u620F"
|
||||
- ARGame
|
||||
- "AR\u904A\u6232"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_Sure2
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "\u786E\u5B9A"
|
||||
- Sure
|
||||
- "\u78BA\u5B9A"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
CaseInsensitiveTerms: 0
|
||||
OnMissingTranslation: 1
|
||||
mTerm_AppName:
|
||||
|
@ -41,7 +41,6 @@ public partial class GameApp : Singleton<GameApp>
|
||||
private void StartGameLogic()
|
||||
{
|
||||
LoadGame().Forget();
|
||||
//GameModule.UI.ShowUI<UIPetInfoWindow>();
|
||||
}
|
||||
|
||||
public async UniTask LoadGame()
|
||||
|
@ -0,0 +1,11 @@
|
||||
using TEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[EventInterface(EEventGroup.GroupUI)]
|
||||
public interface UIARGameInterface
|
||||
{
|
||||
void GetCurGameName(string gamename);
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f936dd990018f3469315eb4967c0550
|
@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[CreateAssetMenu(fileName = "ARGameData", menuName = "ScriptableObjects/ARGameData")]
|
||||
|
||||
public class ARGameScriptableObject : ScriptableObject
|
||||
{
|
||||
[System.Serializable]
|
||||
public class GameData
|
||||
{
|
||||
public string GameName;
|
||||
public string GameImgURL;
|
||||
public bool Lock;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ResponseData
|
||||
{
|
||||
public List<GameData> data;
|
||||
}
|
||||
|
||||
public ResponseData responseData;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56f47294b303de74c913b32dfeabd80d
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 511d8cbcbd21b454c99cb1f774c87be2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36fb130dc753cea4ca9f7e93ac9f0e3f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,97 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI)]
|
||||
public class UIARGameWidget : UIWidget
|
||||
{
|
||||
private int _widgetId;
|
||||
#region 脚本工具生成的代码
|
||||
private Image m_imgMask;
|
||||
private Image m_imgGame;
|
||||
private Button m_btnSelect;
|
||||
private GameObject m_goSelectSate;
|
||||
private Text m_textName;
|
||||
protected override void ScriptGenerator()
|
||||
{
|
||||
m_imgMask = FindChildComponent<Image>("BackGround/m_imgMask");
|
||||
m_imgGame = FindChildComponent<Image>("BackGround/m_imgGame");
|
||||
m_btnSelect = FindChildComponent<Button>("BackGround/m_btnSelect");
|
||||
m_goSelectSate = FindChild("BackGround/m_btnSelect/m_goSelectSate").gameObject;
|
||||
m_textName = FindChildComponent<Text>("BackGround/m_textName");
|
||||
m_btnSelect.onClick.AddListener(UniTask.UnityAction(OnClickSelectBtn));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
private async UniTaskVoid OnClickSelectBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
GameEvent.SendWidgetSelected(_widgetId);
|
||||
|
||||
GameEvent.Send<string>("UIARGameInterface", m_textName.text);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void InitGameFunc(int widgetId, Sprite sP, string gameName, bool islock = true)
|
||||
{
|
||||
_widgetId = widgetId;
|
||||
this.m_imgGame.sprite = sP;
|
||||
this.m_textName.text = gameName;
|
||||
|
||||
LockFunc(islock);
|
||||
|
||||
GameEvent.AddWidgetSelectedListener(OnWidgetSelected);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
GameEvent.RemoveWidgetSelectedListener(OnWidgetSelected);
|
||||
}
|
||||
|
||||
private void OnWidgetSelected(int selectedWidgetId)
|
||||
{
|
||||
if (_widgetId == selectedWidgetId)
|
||||
{
|
||||
OnClickSelect();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnClickSlectCancle();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否激活当前游戏,未激活的游戏图片为黑色
|
||||
/// </summary>
|
||||
/// <param name="islock">是否激活</param>
|
||||
private void LockFunc(bool islock = true)
|
||||
{
|
||||
if (!islock) { m_imgGame.color = Color.white; }
|
||||
m_btnSelect.gameObject.SetActive(!islock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 被选择时,显示被选中状态
|
||||
/// </summary>
|
||||
private void OnClickSelect()
|
||||
{
|
||||
m_imgMask.gameObject.SetActive(true);
|
||||
m_goSelectSate.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消被选择
|
||||
/// </summary>
|
||||
private void OnClickSlectCancle()
|
||||
{
|
||||
m_imgMask.gameObject.SetActive(false);
|
||||
m_goSelectSate.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 747115845ca70e74c9d7243a78e6fda4
|
@ -0,0 +1,113 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
using static PetResponseScriptableObject;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using VoxelBusters.CoreLibrary;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI)]
|
||||
class UIARGameWindow : UIWindow
|
||||
{
|
||||
private string curgamename;
|
||||
|
||||
private ARGameScriptableObject aRGame; // 游戏数据本地配置
|
||||
private const string GAME_DATA_PATH = "ARGameData"; // 游戏数据本地配置路径
|
||||
|
||||
#region 脚本工具生成的代码
|
||||
private GameObject m_goParentGroup;
|
||||
private Button m_btnSure;
|
||||
protected override void ScriptGenerator()
|
||||
{
|
||||
m_goParentGroup = FindChild("Group/ScrollView/Viewport/Content/m_goParentGroup").gameObject;
|
||||
m_btnSure = FindChildComponent<Button>("Mask/m_btnSure");
|
||||
m_btnSure.onClick.AddListener(UniTask.UnityAction(OnClickSureBtn));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
private async UniTaskVoid OnClickSureBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
Debug.LogError(curgamename);
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void RegisterEvent()
|
||||
{
|
||||
base.RegisterEvent();
|
||||
|
||||
GameEvent.AddEventListener<string>(
|
||||
"UIARGameInterface",
|
||||
(gamename) =>
|
||||
{
|
||||
this.curgamename = gamename;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
|
||||
LoadARGameData();
|
||||
|
||||
RegisterEvent();
|
||||
}
|
||||
|
||||
private async void LoadARGameData()
|
||||
{
|
||||
aRGame = GameModule.Resource.LoadAsset<ARGameScriptableObject>(GAME_DATA_PATH);
|
||||
|
||||
if (aRGame == null)
|
||||
{
|
||||
Debug.LogError("加载游戏ARGameScriptableObject配置数据路径错误" + GAME_DATA_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("游戏数据ARGameScriptableObject加载完成.");
|
||||
|
||||
if (aRGame.responseData.data != null && aRGame.responseData.data.Count > 0)
|
||||
{
|
||||
int widgetId = 0;
|
||||
foreach (var tmp in aRGame.responseData.data)
|
||||
{
|
||||
Texture2D texture = await LoadTexture(tmp.GameImgURL);
|
||||
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
||||
var name = ImageUtility.GetImageNameFromUrl(tmp.GameName);
|
||||
if (sprite != null && name != null)
|
||||
{
|
||||
CreateGameWidget(sprite, name, tmp.Lock,widgetId++);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"宠物图片加载失败: {tmp.GameImgURL}或者名字为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("No Game data found in the response.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载纹理
|
||||
private async Task<Texture2D> LoadTexture(string url)
|
||||
{
|
||||
var token = this.gameObject.GetCancellationTokenOnDestroy();
|
||||
var trackImg = await ImageUtility.UnityWebDownloadTexture2D(url, token);
|
||||
|
||||
return trackImg;
|
||||
}
|
||||
|
||||
// 创建宠物信息,设置widget信息
|
||||
private void CreateGameWidget(Sprite sp, string petName,bool islock, int widgetId)
|
||||
{
|
||||
CreateWidgetByPath<UIARGameWidget>(m_goParentGroup.transform, "UIARGameWidget").InitGameFunc(widgetId, sp, petName, islock);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 873415ff80416d74997865a445336ac2
|
@ -593,5 +593,25 @@ namespace TEngine
|
||||
{
|
||||
_eventMgr.Init();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AR游戏事件
|
||||
/// </summary>
|
||||
/// <param name="widgetId"></param>
|
||||
public static void SendWidgetSelected(int widgetId)
|
||||
{
|
||||
_eventMgr.Dispatcher.Send(RuntimeId.ToRuntimeId("WidgetSelected"), widgetId);
|
||||
}
|
||||
|
||||
public static bool AddWidgetSelectedListener(Action<int> handler)
|
||||
{
|
||||
return _eventMgr.Dispatcher.AddEventListener(RuntimeId.ToRuntimeId("WidgetSelected"), handler);
|
||||
}
|
||||
|
||||
public static void RemoveWidgetSelectedListener(Action<int> handler)
|
||||
{
|
||||
_eventMgr.Dispatcher.RemoveEventListener(RuntimeId.ToRuntimeId("WidgetSelected"), handler);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user