完成AR游戏到贪吃蛇UI得脚本切换功能以及UI预制体
This commit is contained in:
parent
2933623b72
commit
caad9f803c
File diff suppressed because one or more lines are too long
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f3e1bad51dfd664fabcdc5b02efb19a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,77 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &5349959040266249335
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1325657813602469064}
|
||||
- component: {fileID: 4433281934468113333}
|
||||
- component: {fileID: 8218021955864646816}
|
||||
m_Layer: 5
|
||||
m_Name: UISnackWidget
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1325657813602469064
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5349959040266249335}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 20, y: 20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &4433281934468113333
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5349959040266249335}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8218021955864646816
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5349959040266249335}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfeba026a63965745bc8e10f92c65887
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
EintooAR/Assets/AssetRaw/UIRaw/Atlas/YL/Snack/Bored.png
Normal file
BIN
EintooAR/Assets/AssetRaw/UIRaw/Atlas/YL/Snack/Bored.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
169
EintooAR/Assets/AssetRaw/UIRaw/Atlas/YL/Snack/Bored.png.meta
Normal file
169
EintooAR/Assets/AssetRaw/UIRaw/Atlas/YL/Snack/Bored.png.meta
Normal file
@ -0,0 +1,169 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed2cc276c35a5f34490181c54294e39c
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 0
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Win64
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -397,14 +397,23 @@ MonoBehaviour:
|
||||
- "AR\u8CAA\u5403\u86C7"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_ARSnackWin
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "\u606D\u559C\u4F60\u6EE1\u5206\u8FC7\u5173\uFF01"
|
||||
- Congratulations on your perfect score!
|
||||
- "\u606D\u559C\u59B3\u6EFF\u5206\u904E\u95DC\uFF01"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_ARSnackPlay
|
||||
TermType: 0
|
||||
Description:
|
||||
Languages:
|
||||
- "\u2191\u70B9\u51FBPlay\u5F00\u59CB\u6E38\u620F\uFF0C\u63A7\u5236\u86C7\u5403\u968F\u673A\u51FA\u73B0\u7684\u98DF\u7269"
|
||||
- "\u2191 Click Play to start the game and control the snake to eat random
|
||||
- "\u2191\u70B9\u51FBPLAY\u5F00\u59CB\u6E38\u620F\uFF0C\u63A7\u5236\u86C7\u5403\u968F\u673A\u51FA\u73B0\u7684\u98DF\u7269"
|
||||
- "\u2191 Click PLAY to start the game and control the snake to eat random
|
||||
food"
|
||||
- "\u2191\u9EDE\u64CAPlay\u958B\u59CB\u904A\u6232\uFF0C\u63A7\u5236\u86C7\u5403\u96A8\u6A5F\u51FA\u73FE\u7684\u98DF\u7269"
|
||||
- "\u2191\u9EDE\u64CAPLAY\u958B\u59CB\u904A\u6232\uFF0C\u63A7\u5236\u86C7\u5403\u96A8\u6A5F\u51FA\u73FE\u7684\u98DF\u7269"
|
||||
Flags: 000000
|
||||
Languages_Touch: []
|
||||
- Term: ar_ARSnackLeft
|
||||
|
@ -32,10 +32,23 @@ namespace GameLogic
|
||||
private async UniTaskVoid OnClickSureBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
Debug.LogError(curgamename);
|
||||
|
||||
LoadGameScene(curgamename);
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void RegisterEvent()
|
||||
{
|
||||
base.RegisterEvent();
|
||||
|
||||
GameEvent.AddEventListener<string>(
|
||||
"UIARGameInterface",
|
||||
(gamename) =>
|
||||
{
|
||||
this.curgamename = gamename;
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
@ -45,18 +58,6 @@ namespace GameLogic
|
||||
RegisterEvent();
|
||||
}
|
||||
|
||||
protected override void RegisterEvent()
|
||||
{
|
||||
base.RegisterEvent();
|
||||
|
||||
GameEvent.AddEventListener<string>(UIARGameInterface_Event.GetCurGameName,GetCurGameName);
|
||||
}
|
||||
|
||||
public void GetCurGameName(string gameName)
|
||||
{
|
||||
this.curgamename = gameName;
|
||||
}
|
||||
|
||||
private async void LoadARGameData()
|
||||
{
|
||||
aRGame = GameModule.Resource.LoadAsset<ARGameScriptableObject>(GAME_DATA_PATH);
|
||||
@ -94,6 +95,17 @@ namespace GameLogic
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadGameScene(string _curgamename)
|
||||
{
|
||||
switch (_curgamename)
|
||||
{
|
||||
case "贪吃蛇":
|
||||
GameModule.UI.ShowUI<UISnackWindow>();
|
||||
GameModule.UI.CloseUI<UIARGameWindow>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载纹理
|
||||
private async Task<Texture2D> LoadTexture(string url)
|
||||
{
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db2bb392719c197469829a89cabfae50
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,21 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI)]
|
||||
class UISnackWidget : UIWidget
|
||||
{
|
||||
#region 脚本工具生成的代码
|
||||
protected override void ScriptGenerator()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f0ebe988c96e5343b8b6c153e141cf1
|
@ -0,0 +1,87 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
using VoxelBusters.CoreLibrary;
|
||||
using UnityEngine.SocialPlatforms.Impl;
|
||||
|
||||
namespace GameLogic
|
||||
{
|
||||
[Window(UILayer.UI)]
|
||||
class UISnackWindow : UIWindow
|
||||
{
|
||||
private int score;
|
||||
|
||||
#region 脚本工具生成的代码
|
||||
private GameObject m_goScoreICon;
|
||||
private Button m_btnPlay;
|
||||
private Text m_textPlay;
|
||||
private Button m_btnLeft;
|
||||
private Button m_btnRight;
|
||||
private Text m_textWin;
|
||||
protected override void ScriptGenerator()
|
||||
{
|
||||
m_goScoreICon = FindChild("Center/Group/ScoreBored/m_goScoreICon").gameObject;
|
||||
m_btnPlay = FindChildComponent<Button>("Center/Group/m_btnPlay");
|
||||
m_textPlay = FindChildComponent<Text>("Center/Group/Bottom/m_textPlay");
|
||||
m_btnLeft = FindChildComponent<Button>("Center/Group/Bottom/Button/m_btnLeft");
|
||||
m_btnRight = FindChildComponent<Button>("Center/Group/Bottom/Button/m_btnRight");
|
||||
m_textWin = FindChildComponent<Text>("Center/m_textWin");
|
||||
m_btnPlay.onClick.AddListener(UniTask.UnityAction(OnClickPlayBtn));
|
||||
m_btnLeft.onClick.AddListener(UniTask.UnityAction(OnClickLeftBtn));
|
||||
m_btnRight.onClick.AddListener(UniTask.UnityAction(OnClickRightBtn));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
private async UniTaskVoid OnClickPlayBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
m_btnPlay.gameObject.SetActive(false);
|
||||
m_textPlay.gameObject.SetActive(false);
|
||||
Debug.Log("贪吃蛇游戏开始");
|
||||
}
|
||||
private async UniTaskVoid OnClickLeftBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
LeftFunc();
|
||||
}
|
||||
private async UniTaskVoid OnClickRightBtn()
|
||||
{
|
||||
await UniTask.Yield();
|
||||
|
||||
RightFunc();
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
|
||||
score = 0;
|
||||
}
|
||||
|
||||
private void CreateScoreWidget()
|
||||
{
|
||||
if (score >= 10)
|
||||
{
|
||||
m_textWin.gameObject.SetActive(true);
|
||||
return;
|
||||
}
|
||||
CreateWidgetByPath<UISnackWidget>(m_goScoreICon.transform, "UISnackWidget");
|
||||
|
||||
score++;
|
||||
}
|
||||
|
||||
private void LeftFunc()
|
||||
{
|
||||
CreateScoreWidget();
|
||||
}
|
||||
|
||||
private void RightFunc()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e688d21c08671cf4483d996523b46817
|
Loading…
x
Reference in New Issue
Block a user