This commit is contained in:
Lucastaa
2026-05-04 10:08:46 +07:00
parent 669930d0b7
commit 5f013bb636
987 changed files with 640226 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class ImageTrackingManager : MonoBehaviour
{
private ARTrackedImageManager trackedImageManager;
// Danh sách các Prefab nhân vật của bạn
public GameObject[] playerPrefabs;
private readonly Dictionary<string, GameObject> spawnedPrefabs = new Dictionary<string, GameObject>();
void Awake() => trackedImageManager = GetComponent<ARTrackedImageManager>();
void OnEnable() => trackedImageManager.trackedImagesChanged += OnChanged;
void OnDisable() => trackedImageManager.trackedImagesChanged -= OnChanged;
void OnChanged(ARTrackedImagesChangedEventArgs eventArgs)
{
// Khi nhận diện thẻ bài mới
foreach (var newImage in eventArgs.added)
{
foreach (var prefab in playerPrefabs)
{
// Nếu tên thẻ bài trong Library khớp với tên Prefab
if (newImage.referenceImage.name == prefab.name && !spawnedPrefabs.ContainsKey(newImage.referenceImage.name))
{
var newPrefab = Instantiate(prefab, newImage.transform);
spawnedPrefabs.Add(newImage.referenceImage.name, newPrefab);
}
}
}
// Khi thẻ bài di chuyển ngoài đời thực, cập nhật vị trí model trong game
foreach (var updatedImage in eventArgs.updated)
{
if (spawnedPrefabs.ContainsKey(updatedImage.referenceImage.name))
{
spawnedPrefabs[updatedImage.referenceImage.name].SetActive(updatedImage.trackingState == UnityEngine.XR.ARSubsystems.TrackingState.Tracking);
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6bf2d8a14ff0de34cb08cd79a11ccd60

View File

@@ -0,0 +1,57 @@
using System;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.PlayerLoop;
using UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets;
namespace Script
{
public class MovementStage : MonoBehaviour
{
private InputActions _inputAction;
private Animator animator;
private Vector2 moveInput;
void Awake()
{
_inputAction = new InputActions();
animator = GetComponent<Animator>();
}
void Start()
{
_inputAction.Player.Move.performed += OnMove;
animator = GetComponent<Animator>();
Debug.Log(animator);
}
private void FixedUpdate()
{
if (moveInput.y > 0)
{
Debug.Log("Moving Forward");
}
}
private void OnMove(InputAction.CallbackContext context)
{
moveInput = context.ReadValue<Vector2>();
bool isMoving = moveInput.magnitude > 0;
animator.SetBool("isWalking", isMoving);
}
void OnEnable()
{
_inputAction.Enable();
_inputAction.Player.Move.performed += OnMove;
_inputAction.Player.Move.canceled += OnMove;
}
void OnDisable()
{
_inputAction.Player.Move.performed -= OnMove;
_inputAction.Player.Move.canceled -= OnMove;
_inputAction.Disable();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: db8f9a37549240e4c8d411daed2ce038

BIN
Assets/Script/QRcode.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@@ -0,0 +1,130 @@
fileFormatVersion: 2
guid: 562e6d522d31fc043a15f9e800962457
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: 0
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: 1
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: 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: 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
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: