Removed TOTU 103
This commit is contained in:
55
Assets/Scripts/ButtonManager.cs
Normal file
55
Assets/Scripts/ButtonManager.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
|
||||
public class ButtonManager : MonoBehaviour
|
||||
{
|
||||
private Button btn;
|
||||
[SerializeField] private RawImage buttonImage;
|
||||
|
||||
public GameObject furniture;
|
||||
|
||||
private int _itemId;
|
||||
private Sprite _buttonTexture;
|
||||
|
||||
public int ItemId
|
||||
{
|
||||
set => _itemId = value;
|
||||
}
|
||||
|
||||
public Sprite ButtonTexture
|
||||
{
|
||||
set
|
||||
{
|
||||
_buttonTexture = value;
|
||||
buttonImage.texture = _buttonTexture.texture;
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
btn = GetComponent<Button>();
|
||||
btn.onClick.AddListener(SelectObject);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (UIManager.Instance.OnEntered(gameObject))
|
||||
{
|
||||
transform.DOScale(Vector3.one * 2, 0.3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.DOScale(Vector3.one, 0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectObject()
|
||||
{
|
||||
DataHandler.Instance.SetFurniture(_itemId);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ButtonManager.cs.meta
Normal file
11
Assets/Scripts/ButtonManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9093f73f765fb624e9a2a77956187992
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Assets/Scripts/DataHandler.cs
Normal file
64
Assets/Scripts/DataHandler.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DataHandler : MonoBehaviour
|
||||
{
|
||||
private GameObject furniture;
|
||||
|
||||
[SerializeField] private ButtonManager buttonPrefab;
|
||||
[SerializeField] private GameObject buttonContainer;
|
||||
[SerializeField] private List<Item> items;
|
||||
|
||||
private int current_id = 0;
|
||||
|
||||
private static DataHandler instance;
|
||||
public static DataHandler Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = FindAnyObjectByType<DataHandler>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
LoadItems();
|
||||
//CreateButton();
|
||||
}
|
||||
|
||||
void LoadItems()
|
||||
{
|
||||
var items_obj = Resources.LoadAll("Items", typeof(Item));
|
||||
|
||||
foreach (var item in items_obj)
|
||||
{
|
||||
items.Add(item as Item);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateButton()
|
||||
{
|
||||
foreach (Item i in items)
|
||||
{
|
||||
ButtonManager b = Instantiate(buttonPrefab, buttonContainer.transform);
|
||||
b.ItemId = current_id;
|
||||
b.ButtonTexture = i.itemImage;
|
||||
current_id++;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFurniture(int id)
|
||||
{
|
||||
furniture = items[id].itemPrefab;
|
||||
}
|
||||
|
||||
public GameObject GetFurniture()
|
||||
{
|
||||
return furniture;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DataHandler.cs.meta
Normal file
11
Assets/Scripts/DataHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95e6d06876545fe47b6fb523677c8833
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/DebugLogger.meta
Normal file
8
Assets/Scripts/DebugLogger.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ed6150b8f0b6d341b31726b62d10a0f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Scripts/DebugLogger/DebugLoggerInitializer.cs
Normal file
19
Assets/Scripts/DebugLogger/DebugLoggerInitializer.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DebugLoggerInitializer : MonoBehaviour
|
||||
{
|
||||
private static bool isInitialized = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!isInitialized)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject); // Evita que este objeto se destruya
|
||||
isInitialized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject); // Previene duplicados
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DebugLogger/DebugLoggerInitializer.cs.meta
Normal file
11
Assets/Scripts/DebugLogger/DebugLoggerInitializer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 237f2195a9d7dd54cb946761ace85155
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Scripts/DebugLogger/DebugLoggerUI.cs
Normal file
34
Assets/Scripts/DebugLogger/DebugLoggerUI.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class DebugLoggerUI : MonoBehaviour
|
||||
{
|
||||
//FindObjectOfType<DebugLoggerUI>().AddMessage("");
|
||||
public TextMeshProUGUI debugText; // Referencia al componente TextMeshPro
|
||||
public int maxMessages = 10; // N<>mero m<>ximo de mensajes visibles
|
||||
|
||||
private List<string> messageList = new List<string>(); // Historial de mensajes
|
||||
|
||||
// M<>todo para a<>adir un mensaje
|
||||
public void AddMessage(string message)
|
||||
{
|
||||
// Si supera el l<>mite, elimina el mensaje m<>s antiguo
|
||||
if (messageList.Count >= maxMessages)
|
||||
{
|
||||
messageList.RemoveAt(0);
|
||||
}
|
||||
|
||||
// A<>adir el mensaje a la lista
|
||||
messageList.Add(message);
|
||||
|
||||
// Actualizar el texto
|
||||
UpdateText();
|
||||
}
|
||||
|
||||
// Actualiza el contenido del texto para mostrar el historial
|
||||
private void UpdateText()
|
||||
{
|
||||
debugText.text = string.Join("\n", messageList); // Combina los mensajes en un solo string
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DebugLogger/DebugLoggerUI.cs.meta
Normal file
11
Assets/Scripts/DebugLogger/DebugLoggerUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fab85559114c59046b1ae8e812bc2163
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/DebugLogger/DebugToggleManager.cs
Normal file
14
Assets/Scripts/DebugLogger/DebugToggleManager.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class DebugToggleManager : MonoBehaviour
|
||||
{
|
||||
public GameObject debugPanel; // El panel que contiene el logger
|
||||
|
||||
public void ToggleDebugPanel()
|
||||
{
|
||||
if (debugPanel != null)
|
||||
{
|
||||
debugPanel.SetActive(!debugPanel.activeSelf);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DebugLogger/DebugToggleManager.cs.meta
Normal file
11
Assets/Scripts/DebugLogger/DebugToggleManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69aa4566e251fc340834b5ecc6a15af5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/Scripts/DebugLogger/PersistentSceneManager.cs
Normal file
23
Assets/Scripts/DebugLogger/PersistentSceneManager.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class PersistentSceneManager : MonoBehaviour
|
||||
{
|
||||
private static bool isInitialized = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!isInitialized)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject); // Previene la destrucci<63>n de este objeto al cambiar de escena
|
||||
isInitialized = true;
|
||||
|
||||
// Cargar la escena principal en modo aditivo
|
||||
SceneManager.LoadScene("MainScreen", LoadSceneMode.Additive);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject); // Evitar duplicados
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/DebugLogger/PersistentSceneManager.cs.meta
Normal file
11
Assets/Scripts/DebugLogger/PersistentSceneManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: caa6ee8d648c1194a9cd77afed65cd90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
114
Assets/Scripts/InputManager.cs
Normal file
114
Assets/Scripts/InputManager.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.Interaction.Toolkit.AR;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class InputManager : ARBaseGestureInteractable
|
||||
{
|
||||
private Camera arCam; // Asignable din<69>micamente
|
||||
private ARRaycastManager _raycastManager; // Asignable din<69>micamente
|
||||
[SerializeField] private GameObject crosshair;
|
||||
|
||||
private List<ARRaycastHit> _hits = new List<ARRaycastHit>();
|
||||
|
||||
private Touch touch;
|
||||
private Pose pose;
|
||||
|
||||
// M<>todo para asignar la c<>mara desde MeasuringSystem
|
||||
public void SetCamera(Camera camera)
|
||||
{
|
||||
arCam = camera;
|
||||
Debug.Log($"C<>mara asignada: {arCam.name}");
|
||||
}
|
||||
|
||||
// M<>todo para asignar el ARRaycastManager desde MeasuringSystem
|
||||
public void SetARRaycastManager(ARRaycastManager raycastManager)
|
||||
{
|
||||
_raycastManager = raycastManager;
|
||||
Debug.Log($"ARRaycastManager asignado: {_raycastManager.name}");
|
||||
}
|
||||
|
||||
protected override bool CanStartManipulationForGesture(TapGesture gesture)
|
||||
{
|
||||
if (gesture.targetObject == null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnEndManipulation(TapGesture gesture)
|
||||
{
|
||||
if (gesture.isCanceled) return;
|
||||
|
||||
if (gesture.targetObject != null && IsPointerOverUI(gesture)) return;
|
||||
|
||||
// Validar referencias antes de ejecutar la l<>gica
|
||||
if (_raycastManager == null)
|
||||
{
|
||||
Debug.LogWarning("ARRaycastManager no asignado. No se puede realizar raycast.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear _hits and use it with the out parameter
|
||||
_hits.Clear();
|
||||
if (_raycastManager.Raycast(gesture.startPosition, _hits, TrackableType.PlaneWithinPolygon))
|
||||
{
|
||||
pose = _hits[0].pose;
|
||||
GameObject placeObj = Instantiate(DataHandler.Instance.GetFurniture(), pose.position, pose.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (arCam == null || _raycastManager == null)
|
||||
{
|
||||
Debug.LogWarning("C<>mara o ARRaycastManager no asignados. No se puede calcular crosshair.");
|
||||
return;
|
||||
}
|
||||
|
||||
CrosshairCalculation();
|
||||
}
|
||||
|
||||
bool IsPointerOverUI(TapGesture touch)
|
||||
{
|
||||
PointerEventData eventData = new PointerEventData(EventSystem.current);
|
||||
eventData.position = new Vector2(touch.startPosition.x, touch.startPosition.y);
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
EventSystem.current.RaycastAll(eventData, results);
|
||||
return results.Count > 0;
|
||||
}
|
||||
|
||||
void CrosshairCalculation()
|
||||
{
|
||||
Vector3 origin = arCam.ViewportToScreenPoint(new Vector3(0.5f, 0.5f, 0));
|
||||
|
||||
// Clear _hits and use it with the out parameter
|
||||
_hits.Clear();
|
||||
if (_raycastManager.Raycast(origin, _hits, TrackableType.PlaneWithinPolygon))
|
||||
{
|
||||
pose = _hits[0].pose;
|
||||
crosshair.transform.position = pose.position;
|
||||
crosshair.transform.eulerAngles = new Vector3(90, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPointInsidePolygon(Vector2 point, List<Vector2> polygon)
|
||||
{
|
||||
int j = polygon.Count - 1;
|
||||
bool inside = false;
|
||||
|
||||
for (int i = 0; i < polygon.Count; j = i++)
|
||||
{
|
||||
if ((polygon[i].y > point.y) != (polygon[j].y > point.y) &&
|
||||
(point.x < (polygon[j].x - polygon[i].x) * (point.y - polygon[i].y) / (polygon[j].y - polygon[i].y) + polygon[i].x))
|
||||
{
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
|
||||
return inside;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/InputManager.cs.meta
Normal file
11
Assets/Scripts/InputManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c341a1cf3bc42847ba6b97b67344e92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
11
Assets/Scripts/Item.cs
Normal file
11
Assets/Scripts/Item.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Item1", menuName = "AddItem/Item")]
|
||||
public class Item : ScriptableObject
|
||||
{
|
||||
public float price;
|
||||
public GameObject itemPrefab;
|
||||
public Sprite itemImage;
|
||||
}
|
||||
11
Assets/Scripts/Item.cs.meta
Normal file
11
Assets/Scripts/Item.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fce0ab03aa03f9741bb6b24e64090902
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Scripts/Marker.png
Normal file
BIN
Assets/Scripts/Marker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
153
Assets/Scripts/Marker.png.meta
Normal file
153
Assets/Scripts/Marker.png.meta
Normal file
@@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e13c5ace7ecc654fbf5e75fdce24e58
|
||||
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: 3
|
||||
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: 3
|
||||
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: 3
|
||||
buildTarget: iPhone
|
||||
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: 3
|
||||
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: 3
|
||||
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
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/MeasuringSystem.meta
Normal file
8
Assets/Scripts/MeasuringSystem.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad9f70e80a5450a46bf4d976803073c4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
432
Assets/Scripts/MeasuringSystem/LineManager.cs
Normal file
432
Assets/Scripts/MeasuringSystem/LineManager.cs
Normal file
@@ -0,0 +1,432 @@
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.Interaction.Toolkit.AR;
|
||||
|
||||
public class LineManager : MonoBehaviour
|
||||
{
|
||||
//Creamos una referencia de 'LineaObjeto'
|
||||
public LineRenderer lineRenderer;
|
||||
//Creamos una referencia a nuestro AR Placement Interactable
|
||||
public ARPlacementInteractable aRPlacementInteractable;
|
||||
//Creamos una referencia al TextoDistancia
|
||||
public TextMeshPro mText;
|
||||
//Creamos unbooleano para delimitar al usuario cuando cierre la forma de los poligonos
|
||||
private bool isPolygonClosed = false;
|
||||
|
||||
// Listas para los objetos y textos colocados
|
||||
private List<GameObject> placedObjects = new List<GameObject>();
|
||||
private List<TextMeshPro> distanceTexts = new List<TextMeshPro>();
|
||||
|
||||
//Referencias a los botones
|
||||
public GameObject cleanButton; // Bot<6F>n de Limpiar
|
||||
public GameObject undoButton; // Bot<6F>n de Deshacer
|
||||
public GameObject confirmButton; // Bot<6F>n de confirmaci<63>n
|
||||
|
||||
//Referencia
|
||||
public ObjectPlacementManager objectPlacementManager; // Referencia al script ObjectPlacementManager.cs
|
||||
|
||||
[SerializeField] private ARPlaneManager arPlaneManager; // Referencia al ARPlaneManager
|
||||
[SerializeField] private Material fillMaterial; // Material con la textura
|
||||
private MeshFilter meshFilter;
|
||||
private MeshRenderer meshRenderer;
|
||||
|
||||
|
||||
public ARRaycastManager arRaycastManager; // Aseg<65>rate de asignar esto en el Inspector
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//aRPlacementInteractable.objectPlaced.AddListener(DrawLine);
|
||||
|
||||
// Configurar MeshFilter y MeshRenderer din<69>micamente
|
||||
// meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||
// meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
||||
// meshRenderer.material = fillMaterial; // Asignar el material en el Inspector
|
||||
// meshRenderer.enabled = false; // Ocultar el MeshRenderer hasta que se confirme
|
||||
SceneManager.LoadScene("ARScreen", LoadSceneMode.Additive);
|
||||
StartCoroutine(AssignManagersToARScreen());
|
||||
}
|
||||
void DrawLine(ARObjectPlacementEventArgs args)
|
||||
{
|
||||
//Si esta cerrado el poligono entonces dejamos de dibujar lineas
|
||||
if (isPolygonClosed) return; // Detenemos si el pol<6F>gono est<73> cerrado
|
||||
|
||||
// Colocar punto
|
||||
placedObjects.Add(args.placementObject); // Registrar el objeto colocado
|
||||
|
||||
|
||||
//increase point count
|
||||
lineRenderer.positionCount++;
|
||||
|
||||
//2. let the points location in the line renderer
|
||||
lineRenderer.SetPosition(
|
||||
index: lineRenderer.positionCount - 1,//La linea se crea desde el objeto colocado anteriormente
|
||||
args.placementObject.transform.position//Hasta el nuevo objeto colocado
|
||||
);
|
||||
//Mientras tengamos una linea o mas de un punto, entonces se puede crear el texto de medicion
|
||||
if (lineRenderer.positionCount > 1)
|
||||
{
|
||||
//Distancia del ultimo punto colocado
|
||||
Vector3 pointA = lineRenderer.GetPosition(index: lineRenderer.positionCount - 1);
|
||||
//Distancia del punto anterior al ultimo colocado (penultimo punto)
|
||||
Vector3 pointB = lineRenderer.GetPosition(index: lineRenderer.positionCount - 2);
|
||||
//Objtenem,os la distancia entre los dos puntos
|
||||
float distancia = Vector3.Distance(pointA, pointB);
|
||||
//Colocamos el texto de la distancia en TextoDistancia se mostrara en cm ejemplo de salida: 10.009 cm
|
||||
//mText.text = (distancia * 100).ToString("0.000") + " cm";
|
||||
//crearemos un TextoDistancia en cada linea cada vez que se genere una.
|
||||
TextMeshPro textoDistanciaTemp = Instantiate(mText);
|
||||
textoDistanciaTemp.text = (distancia * 100).ToString("0.000") + " cm";
|
||||
//aplicamos un formato al texto para que se coloque encima de la linea
|
||||
Vector3 directionVector = (pointB - pointA);
|
||||
Vector3 normal = args.placementObject.transform.up;
|
||||
|
||||
Vector3 upd = Vector3.Cross(
|
||||
lhs: directionVector,
|
||||
rhs: normal).normalized;
|
||||
//calculamos la rotacion del texto
|
||||
Quaternion rotation = Quaternion.LookRotation(forward: -normal, upwards: upd);
|
||||
//aplicamos la posicion y rotacion al texto
|
||||
textoDistanciaTemp.transform.position = (pointA + directionVector * 0.5f) + upd * 0.05f;
|
||||
textoDistanciaTemp.transform.rotation = rotation;
|
||||
|
||||
distanceTexts.Add(textoDistanciaTemp); // Registrar el texto de distancia
|
||||
}
|
||||
//Si los botones de limpiar y deshacer estan desactivados alcolocar una linea u objeto, entonces los activamos
|
||||
if (!cleanButton.activeSelf && !undoButton.activeSelf)
|
||||
{
|
||||
//Agregamos los botones a la pantalla al agregar un punto
|
||||
cleanButton.SetActive(true);
|
||||
undoButton.SetActive(true);
|
||||
}
|
||||
//Verificamos si es posiblie cerrar el poligono
|
||||
CheckPolygonClosure();
|
||||
}
|
||||
|
||||
//Este metodo determina si se pueden continuar insertando o no mas lineas
|
||||
private void CheckPolygonClosure()
|
||||
{
|
||||
if (lineRenderer.positionCount > 2)
|
||||
{
|
||||
Vector3 firstPoint = lineRenderer.GetPosition(0);
|
||||
Vector3 lastPoint = lineRenderer.GetPosition(lineRenderer.positionCount - 1);
|
||||
|
||||
float distanceToFirst = Vector3.Distance(lastPoint, firstPoint);
|
||||
|
||||
if (distanceToFirst < 0.03f) // Define el margen de cierre en 3 cm
|
||||
{
|
||||
isPolygonClosed = true;//En caso de que la proxima linea este cerca de la primera entonces volvemos true
|
||||
|
||||
// Cambiar color del pol<6F>gono para indicar cierre
|
||||
lineRenderer.material.color = Color.green;
|
||||
|
||||
// Deshabilitar el ARPlacementInteractable para evitar m<>s colocaciones
|
||||
aRPlacementInteractable.enabled = false;
|
||||
|
||||
// Activar el bot<6F>n de confirmaci<63>n
|
||||
confirmButton.SetActive(true);
|
||||
|
||||
|
||||
// Mostrar mensaje al usuario
|
||||
Debug.Log("Pol<6F>gono cerrado. No se pueden agregar m<>s puntos.");
|
||||
//FindObjectOfType<DebugLoggerUI>().AddMessage("Pol<6F>gono cerrado. No se pueden agregar m<>s puntos.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Este metodo limpia los poligonos de la camara
|
||||
public void ResetPolygon()
|
||||
{
|
||||
if (isPolygonClosed)
|
||||
{
|
||||
//Quitamos de pantalla boton confirmar
|
||||
confirmButton.SetActive(false);
|
||||
}
|
||||
// Reiniciar la l<>gica del pol<6F>gono
|
||||
isPolygonClosed = false;
|
||||
aRPlacementInteractable.enabled = true;
|
||||
|
||||
// Limpiar las l<>neas
|
||||
lineRenderer.positionCount = 0;
|
||||
lineRenderer.material.color = Color.red;
|
||||
|
||||
// Destruir objetos colocados
|
||||
foreach (GameObject obj in placedObjects)
|
||||
{
|
||||
Destroy(obj);
|
||||
}
|
||||
placedObjects.Clear();
|
||||
|
||||
// Destruir textos de distancia
|
||||
foreach (TextMeshPro text in distanceTexts)
|
||||
{
|
||||
Destroy(text.gameObject);
|
||||
}
|
||||
distanceTexts.Clear();
|
||||
//Quitamos los botones de limpiar y deshacer de la pantalla
|
||||
cleanButton.SetActive(false);
|
||||
undoButton.SetActive(false);
|
||||
|
||||
Debug.Log("Pol<6F>gono reiniciado.");
|
||||
}
|
||||
|
||||
//Este metodo se encarga de deshacer los cambios del usuario
|
||||
public void UndoLastAction()
|
||||
{
|
||||
// Verificar que haya puntos para deshacer
|
||||
if (placedObjects.Count > 0)
|
||||
{
|
||||
// Eliminar el <20>ltimo punto colocado
|
||||
GameObject lastObject = placedObjects[placedObjects.Count - 1];
|
||||
Destroy(lastObject);
|
||||
placedObjects.RemoveAt(placedObjects.Count - 1);
|
||||
|
||||
// Eliminar el <20>ltimo texto de distancia, si existe
|
||||
if (distanceTexts.Count > 0)
|
||||
{
|
||||
TextMeshPro lastText = distanceTexts[distanceTexts.Count - 1];
|
||||
Destroy(lastText.gameObject);
|
||||
distanceTexts.RemoveAt(distanceTexts.Count - 1);
|
||||
}
|
||||
|
||||
// Actualizar el LineRenderer
|
||||
if (lineRenderer.positionCount > 0)
|
||||
{
|
||||
lineRenderer.positionCount--; // Reduce el conteo de puntos
|
||||
|
||||
// Si el poligono ya estaba cerrado lo volvemos a habilitar
|
||||
if (isPolygonClosed)
|
||||
{
|
||||
isPolygonClosed = false;
|
||||
aRPlacementInteractable.enabled = true;
|
||||
lineRenderer.material.color = Color.red;// Cambiar color del pol<6F>gono
|
||||
//Quitamos de pantalla boton confirmar
|
||||
confirmButton.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
//Si no tenemos ningun objeto entonces quitamos los botones de limpiar
|
||||
if (placedObjects.Count == 0)
|
||||
{
|
||||
//Agregamos los botones a la pantalla al agregar un punto
|
||||
cleanButton.SetActive(false);
|
||||
undoButton.SetActive(false);
|
||||
}
|
||||
Debug.Log("<22>ltima acci<63>n deshecha.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("No hay acciones para deshacer.");
|
||||
}
|
||||
}
|
||||
|
||||
//Confirmar el seteo de objetos
|
||||
public void ConfirmPlacement()
|
||||
{
|
||||
if (!isPolygonClosed)
|
||||
{
|
||||
Debug.Log("No se puede confirmar: el pol<6F>gono no est<73> cerrado.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("Confirmaci<63>n completada: Solo se pueden colocar objetos dentro del <20>rea seleccionada.");
|
||||
|
||||
// Generar el Mesh del pol<6F>gono
|
||||
GeneratePolygonMesh(GetPolygonPoints());
|
||||
|
||||
// Cambiar la l<>gica del ARPlacementInteractable
|
||||
aRPlacementInteractable.objectPlaced.RemoveListener(DrawLine); // Quitar la l<>gica de dibujo
|
||||
aRPlacementInteractable.objectPlaced.AddListener(ValidatePlacement); // Agregar la validaci<63>n
|
||||
//aRPlacementInteractable.enabled = true;
|
||||
|
||||
// Detener la detecci<63>n de planos y ocultar los existentes
|
||||
if (arPlaneManager != null)
|
||||
{
|
||||
arPlaneManager.enabled = false;
|
||||
|
||||
foreach (var plane in arPlaneManager.trackables)
|
||||
{
|
||||
plane.gameObject.SetActive(false);
|
||||
}
|
||||
Debug.Log("Detecci<63>n de planos detenida y planos ocultos.");
|
||||
}
|
||||
|
||||
//Quitamos los botones de la pantalla
|
||||
cleanButton.SetActive(false);
|
||||
undoButton.SetActive(false);
|
||||
confirmButton.SetActive(false);
|
||||
|
||||
// Cargar ARScreen en modo aditivo
|
||||
SceneManager.LoadScene("ARScreen", LoadSceneMode.Additive);
|
||||
Debug.Log("ARScreen cargado en modo aditivo.");
|
||||
//FindObjectOfType<DebugLoggerUI>().AddMessage("ARScreen cargado en modo aditivo.");
|
||||
|
||||
// Asignar la c<>mara y el ARRaycastManager a los scripts en ARScreen
|
||||
StartCoroutine(AssignManagersToARScreen());
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator AssignManagersToARScreen()
|
||||
{
|
||||
yield return null; // Esperar un frame para que ARScreen se cargue
|
||||
|
||||
Camera measuringCamera = Camera.main;
|
||||
|
||||
if (measuringCamera == null)
|
||||
{
|
||||
Debug.LogError("C<>mara principal no encontrada en la nueva escena.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
ARRaycastManager raycastManager = FindObjectOfType<ARRaycastManager>();
|
||||
if (raycastManager == null)
|
||||
{
|
||||
Debug.LogError("ARRaycastManager no encontrado en la nueva escena.");
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var dragManager in FindObjectsOfType<DragAndDropManager>())
|
||||
{
|
||||
dragManager.SetCamera(measuringCamera);
|
||||
dragManager.SetARRaycastManager(raycastManager);
|
||||
}
|
||||
|
||||
foreach (var objectSelector in FindObjectsOfType<ObjectSelector>())
|
||||
{
|
||||
objectSelector.SetCamera(measuringCamera);
|
||||
objectSelector.SetARRaycastManager(raycastManager);
|
||||
}
|
||||
|
||||
Debug.Log("C<>mara y ARRaycastManager asignados a ARScreen.");
|
||||
//FindObjectOfType<DebugLoggerUI>().AddMessage("C<>mara y ARRaycastManager asignados a ARScreen.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Limitar area de seto de objetos
|
||||
void ValidatePlacement(ARObjectPlacementEventArgs args)
|
||||
{
|
||||
Debug.Log($"Intentando colocar objeto en: {args.placementObject.transform.position}");
|
||||
// Validar la posici<63>n del objeto antes de colocarlo
|
||||
objectPlacementManager.PlaceObject(args.placementObject.transform.position);
|
||||
Destroy(args.placementObject); // Eliminar el objeto temporal si est<73> fuera del <20>rea
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Metodos publicos para compartir datos a otros scripts
|
||||
*
|
||||
* **/
|
||||
public bool IsPolygonClosed()
|
||||
{
|
||||
return isPolygonClosed;
|
||||
}
|
||||
|
||||
public List<Vector3> GetPolygonPoints()
|
||||
{
|
||||
List<Vector3> points = new List<Vector3>();
|
||||
for (int i = 0; i < lineRenderer.positionCount; i++)
|
||||
{
|
||||
points.Add(lineRenderer.GetPosition(i));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
public bool IsPointInPolygon(Vector2 point, List<Vector3> polygon)
|
||||
{
|
||||
int intersections = 0;
|
||||
for (int i = 0; i < polygon.Count; i++)
|
||||
{
|
||||
Vector3 vertex1 = polygon[i];
|
||||
Vector3 vertex2 = polygon[(i + 1) % polygon.Count];
|
||||
|
||||
if (RayIntersectsSegment(point, new Vector2(vertex1.x, vertex1.z), new Vector2(vertex2.x, vertex2.z)))
|
||||
{
|
||||
intersections++;
|
||||
}
|
||||
}
|
||||
Debug.DrawLine(new Vector3(point.x, 0, point.y), new Vector3(point.x, 1, point.y), Color.red, 5f);
|
||||
|
||||
return (intersections % 2) != 0; // Punto est<73> dentro si intersecciones es impar
|
||||
}
|
||||
|
||||
private bool RayIntersectsSegment(Vector2 point, Vector2 vertex1, Vector2 vertex2)
|
||||
{
|
||||
// Checa si el rayo desde el punto cruza el segmento
|
||||
if (vertex1.y > vertex2.y)
|
||||
{
|
||||
Vector2 temp = vertex1;
|
||||
vertex1 = vertex2;
|
||||
vertex2 = temp;
|
||||
}
|
||||
|
||||
if (point.y == vertex1.y || point.y == vertex2.y)
|
||||
{
|
||||
//point.y += 0.0001f; // Evita bordes exactos
|
||||
point.y += 0.001f; // Ajusta este valor para evitar problemas en bordes
|
||||
}
|
||||
|
||||
if (point.y < vertex1.y || point.y > vertex2.y || point.x > Mathf.Max(vertex1.x, vertex2.x))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (point.x < Mathf.Min(vertex1.x, vertex2.x))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
float red = (point.y - vertex1.y) / (vertex2.y - vertex1.y);
|
||||
float blue = (point.x - vertex1.x) / (vertex2.x - vertex1.x);
|
||||
return red >= blue;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region pintar poligono
|
||||
private void GeneratePolygonMesh(List<Vector3> polygonPoints)
|
||||
{
|
||||
if (polygonPoints.Count < 3)
|
||||
{
|
||||
Debug.LogError("El pol<6F>gono debe tener al menos 3 puntos.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Crear un nuevo Mesh
|
||||
Mesh mesh = new Mesh();
|
||||
|
||||
// Convertir los puntos del pol<6F>gono a un array de Vector3
|
||||
Vector3[] vertices = polygonPoints.ToArray();
|
||||
|
||||
// Generar <20>ndices para triangulaci<63>n (simple para pol<6F>gonos convexos)
|
||||
List<int> indices = new List<int>();
|
||||
for (int i = 1; i < polygonPoints.Count - 1; i++)
|
||||
{
|
||||
indices.Add(0);
|
||||
indices.Add(i);
|
||||
indices.Add(i + 1);
|
||||
}
|
||||
|
||||
// Asignar los v<>rtices y tri<72>ngulos al Mesh
|
||||
mesh.vertices = vertices;
|
||||
mesh.triangles = indices.ToArray();
|
||||
|
||||
// Generar UVs para aplicar la textura
|
||||
Vector2[] uvs = new Vector2[vertices.Length];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
uvs[i] = new Vector2(vertices[i].x, vertices[i].z); // UV mapping en XZ
|
||||
}
|
||||
mesh.uv = uvs;
|
||||
|
||||
// Asignar el Mesh al MeshFilter
|
||||
mesh.RecalculateNormals();
|
||||
mesh.RecalculateBounds();
|
||||
meshFilter.mesh = mesh;
|
||||
|
||||
// Activar el MeshRenderer para mostrar la textura
|
||||
meshRenderer.enabled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
11
Assets/Scripts/MeasuringSystem/LineManager.cs.meta
Normal file
11
Assets/Scripts/MeasuringSystem/LineManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6b7189cb06ada841952b0acbcba8f8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/MeasuringSystem/ObjectPlacementManager.cs
Normal file
33
Assets/Scripts/MeasuringSystem/ObjectPlacementManager.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ObjectPlacementManager : MonoBehaviour
|
||||
{
|
||||
public LineManager lineManager; // Referencia al script LineManager
|
||||
public GameObject myPrefab;
|
||||
|
||||
public void PlaceObject(Vector3 position)
|
||||
{
|
||||
if (!lineManager.IsPolygonClosed())
|
||||
{
|
||||
Debug.Log("No se puede colocar objetos: el pol<6F>gono no est<73> cerrado.");
|
||||
FindObjectOfType<DebugLoggerUI>().AddMessage("No se puede colocar objetos: el pol<6F>gono no est<73> cerrado.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<Vector3> polygon = lineManager.GetPolygonPoints();
|
||||
Vector2 point2D = new Vector2(position.x, position.z);
|
||||
|
||||
if (!lineManager.IsPointInPolygon(point2D, polygon))
|
||||
{
|
||||
Debug.Log("El punto est<73> fuera del <20>rea permitida.");
|
||||
FindObjectOfType<DebugLoggerUI>().AddMessage("El punto est<73> fuera del <20>rea permitida.");
|
||||
return;
|
||||
}
|
||||
|
||||
Instantiate(myPrefab, position, Quaternion.identity);
|
||||
Debug.Log("Objeto colocado dentro del <20>rea.");
|
||||
FindObjectOfType<DebugLoggerUI>().AddMessage("Objeto colocado dentro del <20>rea.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc9cb48456cd18749ad637e8dc6117a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Scripts/MeasuringSystem/WelcomeMessageManager.cs
Normal file
30
Assets/Scripts/MeasuringSystem/WelcomeMessageManager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class WelcomeMessageManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject welcomeMessage; // Asigna el texto en el Inspector
|
||||
[SerializeField] private float displayDuration = 5f; // Duraci<63>n del mensaje en segundos
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Mostrar el mensaje al iniciar
|
||||
if (welcomeMessage != null)
|
||||
{
|
||||
welcomeMessage.SetActive(true);
|
||||
// Ocultar el mensaje despu<70>s de la duraci<63>n especificada
|
||||
Invoke(nameof(HideWelcomeMessage), displayDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("No se ha asignado el mensaje de bienvenida.");
|
||||
}
|
||||
}
|
||||
|
||||
private void HideWelcomeMessage()
|
||||
{
|
||||
if (welcomeMessage != null)
|
||||
{
|
||||
welcomeMessage.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/MeasuringSystem/WelcomeMessageManager.cs.meta
Normal file
11
Assets/Scripts/MeasuringSystem/WelcomeMessageManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e025b44b60acf2a4bb7921c3f10be3f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/Scripts/NewBehaviourScript.cs
Normal file
110
Assets/Scripts/NewBehaviourScript.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
/// <summary>
|
||||
/// This plane visualizer demonstrates the use of a feathering effect
|
||||
/// at the edge of the detected plane, which reduces the visual impression
|
||||
/// of a hard edge.
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(ARPlaneMeshVisualizer), typeof(MeshRenderer), typeof(ARPlane))]
|
||||
public class NewBehaviourScript : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The width of the texture feathering (in world units).")]
|
||||
[SerializeField]
|
||||
float m_FeatheringWidth = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// The width of the texture feathering (in world units).
|
||||
/// </summary>
|
||||
public float featheringWidth
|
||||
{
|
||||
get { return m_FeatheringWidth; }
|
||||
set { m_FeatheringWidth = value; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
m_PlaneMeshVisualizer = GetComponent<ARPlaneMeshVisualizer>();
|
||||
m_FeatheredPlaneMaterial = GetComponent<MeshRenderer>().material;
|
||||
m_Plane = GetComponent<ARPlane>();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_Plane.boundaryChanged += ARPlane_boundaryUpdated;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
m_Plane.boundaryChanged -= ARPlane_boundaryUpdated;
|
||||
}
|
||||
|
||||
void ARPlane_boundaryUpdated(ARPlaneBoundaryChangedEventArgs eventArgs)
|
||||
{
|
||||
GenerateBoundaryUVs(m_PlaneMeshVisualizer.mesh);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate UV2s to mark the boundary vertices and feathering UV coords.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The <c>ARPlaneMeshVisualizer</c> has a <c>meshUpdated</c> event that can be used to modify the generated
|
||||
/// mesh. In this case we'll add UV2s to mark the boundary vertices.
|
||||
/// This technique avoids having to generate extra vertices for the boundary. It works best when the plane is
|
||||
/// is fairly uniform.
|
||||
/// </remarks>
|
||||
/// <param name="mesh">The <c>Mesh</c> generated by <c>ARPlaneMeshVisualizer</c></param>
|
||||
void GenerateBoundaryUVs(Mesh mesh)
|
||||
{
|
||||
int vertexCount = mesh.vertexCount;
|
||||
|
||||
// Reuse the list of UVs
|
||||
s_FeatheringUVs.Clear();
|
||||
if (s_FeatheringUVs.Capacity < vertexCount) { s_FeatheringUVs.Capacity = vertexCount; }
|
||||
|
||||
mesh.GetVertices(s_Vertices);
|
||||
|
||||
Vector3 centerInPlaneSpace = s_Vertices[s_Vertices.Count - 1];
|
||||
Vector3 uv = new Vector3(0, 0, 0);
|
||||
float shortestUVMapping = float.MaxValue;
|
||||
|
||||
// Assume the last vertex is the center vertex.
|
||||
for (int i = 0; i < vertexCount - 1; i++)
|
||||
{
|
||||
float vertexDist = Vector3.Distance(s_Vertices[i], centerInPlaneSpace);
|
||||
|
||||
// Remap the UV so that a UV of "1" marks the feathering boudary.
|
||||
// The ratio of featherBoundaryDistance/edgeDistance is the same as featherUV/edgeUV.
|
||||
// Rearrange to get the edge UV.
|
||||
float uvMapping = vertexDist / Mathf.Max(vertexDist - featheringWidth, 0.001f);
|
||||
uv.x = uvMapping;
|
||||
|
||||
// All the UV mappings will be different. In the shader we need to know the UV value we need to fade out by.
|
||||
// Choose the shortest UV to guarentee we fade out before the border.
|
||||
// This means the feathering widths will be slightly different, we again rely on a fairly uniform plane.
|
||||
if (shortestUVMapping > uvMapping) { shortestUVMapping = uvMapping; }
|
||||
|
||||
s_FeatheringUVs.Add(uv);
|
||||
}
|
||||
|
||||
m_FeatheredPlaneMaterial.SetFloat("_ShortestUVMapping", shortestUVMapping);
|
||||
|
||||
// Add the center vertex UV
|
||||
uv.Set(0, 0, 0);
|
||||
s_FeatheringUVs.Add(uv);
|
||||
|
||||
mesh.SetUVs(1, s_FeatheringUVs);
|
||||
mesh.UploadMeshData(false);
|
||||
}
|
||||
|
||||
static List<Vector3> s_FeatheringUVs = new List<Vector3>();
|
||||
|
||||
static List<Vector3> s_Vertices = new List<Vector3>();
|
||||
|
||||
ARPlaneMeshVisualizer m_PlaneMeshVisualizer;
|
||||
|
||||
ARPlane m_Plane;
|
||||
|
||||
Material m_FeatheredPlaneMaterial;
|
||||
}
|
||||
11
Assets/Scripts/NewBehaviourScript.cs.meta
Normal file
11
Assets/Scripts/NewBehaviourScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7233555a922d4569a102467f863b3dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ObjectDetection.meta
Normal file
8
Assets/Scripts/ObjectDetection.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2533ce6a0e23d914893c38dbb4ab74fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/Scripts/ObjectDetection/DrawRect.cs
Normal file
46
Assets/Scripts/ObjectDetection/DrawRect.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2022-2024 Niantic.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DrawRect : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject _rectanglePrefab;
|
||||
|
||||
private List<UIRectObject> _rectangleObjects = new List<UIRectObject>();
|
||||
private List<int> _openIndices = new List<int>();
|
||||
|
||||
public void CreateRect(Rect rect, Color color, string text)
|
||||
{
|
||||
if (_openIndices.Count == 0)
|
||||
{
|
||||
var newRect = Instantiate(_rectanglePrefab, parent: this.transform).GetComponent<UIRectObject>();
|
||||
|
||||
_rectangleObjects.Add(newRect);
|
||||
_openIndices.Add(_rectangleObjects.Count - 1);
|
||||
}
|
||||
|
||||
// Treat the first index as a queue
|
||||
int index = _openIndices[0];
|
||||
_openIndices.RemoveAt(0);
|
||||
|
||||
UIRectObject rectangle = _rectangleObjects[index];
|
||||
rectangle.SetRectTransform(rect);
|
||||
rectangle.SetColor(color);
|
||||
rectangle.SetText(text);
|
||||
rectangle.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void ClearRects()
|
||||
{
|
||||
for (var i = 0; i < _rectangleObjects.Count; i++)
|
||||
{
|
||||
_rectangleObjects[i].gameObject.SetActive(false);
|
||||
_openIndices.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Scripts/ObjectDetection/DrawRect.cs.meta
Normal file
11
Assets/Scripts/ObjectDetection/DrawRect.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a81c7be58bc4e46f0af9022ac8704397
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
150
Assets/Scripts/ObjectDetection/ObjectDetectionSample.cs
Normal file
150
Assets/Scripts/ObjectDetection/ObjectDetectionSample.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using Niantic.Lightship.AR.ObjectDetection;
|
||||
using UnityEngine;
|
||||
|
||||
public class ObjectDetectionSample : MonoBehaviour
|
||||
{
|
||||
private ARObjectDetectionManager _objectDetectionManager;
|
||||
[SerializeField]
|
||||
private DrawRect _drawRect;
|
||||
|
||||
private Camera _mainCamera;
|
||||
private Canvas _canvas;
|
||||
|
||||
private Color[] _colors = new Color[]
|
||||
{
|
||||
Color.red, Color.blue, Color.green, Color.yellow, Color.magenta,
|
||||
Color.cyan, Color.white, Color.black
|
||||
};
|
||||
|
||||
private Vector3 _lastCameraPosition;
|
||||
private float _movementThreshold = 0.005f; // Adjust for sensitivity
|
||||
private float _detectionSlowdownRate = 0.0f; // Detection frame rate for stationary camera
|
||||
private float _detectionNormalRate = 1.0f; // Detection frame rate for moving camera
|
||||
private bool _isCameraMoving = false;
|
||||
private float confidencePercentage = 0.65f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_mainCamera = Camera.main;
|
||||
if (_mainCamera == null)
|
||||
{
|
||||
Debug.LogError("Main Camera not found.");
|
||||
}
|
||||
|
||||
_objectDetectionManager = FindObjectOfType<ARObjectDetectionManager>();
|
||||
if (_objectDetectionManager == null)
|
||||
{
|
||||
Debug.LogError("ARObjectDetectionManager not found.");
|
||||
}
|
||||
|
||||
_canvas = FindObjectOfType<Canvas>();
|
||||
if (_canvas == null)
|
||||
{
|
||||
Debug.LogError("Canvas not found.");
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_objectDetectionManager != null)
|
||||
{
|
||||
_objectDetectionManager.enabled = true;
|
||||
_objectDetectionManager.ObjectDetectionsUpdated += ObjectDetectionsUpdated;
|
||||
Debug.Log("Object detection started.");
|
||||
}
|
||||
|
||||
_lastCameraPosition = _mainCamera.transform.position;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
DetectCameraMovement();
|
||||
}
|
||||
|
||||
private void DetectCameraMovement()
|
||||
{
|
||||
if (_mainCamera == null) return;
|
||||
|
||||
Vector3 currentCameraPosition = _mainCamera.transform.position;
|
||||
float movement = Vector3.Distance(currentCameraPosition, _lastCameraPosition);
|
||||
|
||||
Debug.Log($"Camera Movement Detected: {movement}");
|
||||
|
||||
if (movement > _movementThreshold)
|
||||
{
|
||||
if (!_isCameraMoving)
|
||||
{
|
||||
// Resume full frame rate for detection
|
||||
_isCameraMoving = true;
|
||||
SetDetectionFrameRate(_detectionNormalRate);
|
||||
Debug.Log("Camera is moving, increasing detection rate.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isCameraMoving)
|
||||
{
|
||||
// Slow down detection to save performance
|
||||
_isCameraMoving = false;
|
||||
SetDetectionFrameRate(_detectionSlowdownRate);
|
||||
Debug.Log("Camera is stationary, slowing detection rate.");
|
||||
}
|
||||
}
|
||||
|
||||
_lastCameraPosition = currentCameraPosition;
|
||||
}
|
||||
|
||||
private void SetDetectionFrameRate(float frameRate)
|
||||
{
|
||||
if (_objectDetectionManager != null)
|
||||
{
|
||||
_objectDetectionManager.TargetFrameRate = (uint)frameRate;
|
||||
}
|
||||
}
|
||||
|
||||
private void ObjectDetectionsUpdated(ARObjectDetectionsUpdatedEventArgs args)
|
||||
{
|
||||
if (_mainCamera == null || _objectDetectionManager == null) return;
|
||||
|
||||
var result = args.Results;
|
||||
if (result == null || result.Count == 0)
|
||||
{
|
||||
Debug.Log("No detections found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"Detections found: {result.Count}");
|
||||
|
||||
_drawRect.ClearRects();
|
||||
|
||||
for (int i = 0; i < result.Count; i++)
|
||||
{
|
||||
var detection = result[i];
|
||||
if (detection.GetConfidentCategorizations().Count == 0) continue;
|
||||
|
||||
var categoryToDisplay = detection.GetConfidentCategorizations()[0];
|
||||
float confidence = categoryToDisplay.Confidence;
|
||||
|
||||
if (confidence <= confidencePercentage) continue; // Adjust threshold if needed
|
||||
|
||||
string categoryName = categoryToDisplay.CategoryName;
|
||||
|
||||
int h = Mathf.FloorToInt(_canvas.GetComponent<RectTransform>().rect.height);
|
||||
int w = Mathf.FloorToInt(_canvas.GetComponent<RectTransform>().rect.width);
|
||||
var rect = detection.CalculateRect(w, h, Screen.orientation);
|
||||
|
||||
Debug.Log($"Detected: {categoryName} with confidence {confidence * 100:F1}%");
|
||||
|
||||
string label = $"{categoryName} {confidence * 100:F1}%";
|
||||
_drawRect.CreateRect(rect, _colors[i % _colors.Length], label);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (_objectDetectionManager != null)
|
||||
{
|
||||
_objectDetectionManager.ObjectDetectionsUpdated -= ObjectDetectionsUpdated;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ObjectDetection/ObjectDetectionSample.cs.meta
Normal file
11
Assets/Scripts/ObjectDetection/ObjectDetectionSample.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce4b4913151ce4b2594ebfe2f7be8abe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/Scripts/ObjectDetection/UIRectObject.cs
Normal file
43
Assets/Scripts/ObjectDetection/UIRectObject.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2022-2024 Niantic.
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(RectTransform), typeof(Image))]
|
||||
public class UIRectObject : MonoBehaviour
|
||||
{
|
||||
private RectTransform _rectangleRectTransform;
|
||||
private Image _rectangleImage;
|
||||
private Text _text;
|
||||
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_rectangleRectTransform = GetComponent<RectTransform>();
|
||||
_rectangleImage = GetComponent<Image>();
|
||||
_text = GetComponentInChildren<Text>();
|
||||
}
|
||||
|
||||
public void SetRectTransform(Rect rect)
|
||||
{
|
||||
_rectangleRectTransform.anchoredPosition = new Vector2(rect.x, rect.y);
|
||||
_rectangleRectTransform.sizeDelta = new Vector2(rect.width, rect.height);
|
||||
}
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
_rectangleImage.color = color;
|
||||
}
|
||||
|
||||
public void SetText(string text)
|
||||
{
|
||||
_text.text = text;
|
||||
}
|
||||
public RectTransform getRectTransform(){
|
||||
return _rectangleRectTransform;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ObjectDetection/UIRectObject.cs.meta
Normal file
11
Assets/Scripts/ObjectDetection/UIRectObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 326123b510dc140f48475dfc0d614976
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Scripts/SceneLoader.cs
Normal file
32
Assets/Scripts/SceneLoader.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class SceneLoader : MonoBehaviour
|
||||
{
|
||||
public string sceneToLoad = "ObjectDetection";
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Cargar la escena adicional en modo aditivo
|
||||
SceneManager.LoadScene(sceneToLoad, LoadSceneMode.Additive);
|
||||
|
||||
// Opcional: desactivar c<>maras redundantes en la escena adicional
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
if (scene.name == sceneToLoad)
|
||||
{
|
||||
var cameras = scene.GetRootGameObjects();
|
||||
foreach (var obj in cameras)
|
||||
{
|
||||
var camera = obj.GetComponentInChildren<Camera>();
|
||||
if (camera != null)
|
||||
{
|
||||
camera.enabled = false; // Desactivar c<>maras adicionales
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SceneLoader.cs.meta
Normal file
11
Assets/Scripts/SceneLoader.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df827e13739314e45a7f6f266992b6d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/Scripts/UIContentFitter.cs
Normal file
24
Assets/Scripts/UIContentFitter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIContentFitter : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
HorizontalLayoutGroup hg = GetComponent<HorizontalLayoutGroup>();
|
||||
int childCount = transform.childCount - 1;
|
||||
float childWidth = transform.GetChild(0).GetComponent<RectTransform>().rect.width;
|
||||
float width = hg.spacing * childCount + childCount * childWidth + hg.padding.left;
|
||||
|
||||
GetComponent<RectTransform>().sizeDelta = new Vector2(width, 265);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UIContentFitter.cs.meta
Normal file
11
Assets/Scripts/UIContentFitter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86b533a2be9a2ab40a74435e9fd82148
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/Scripts/UIManager.cs
Normal file
52
Assets/Scripts/UIManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
private GraphicRaycaster raycaster;
|
||||
private PointerEventData pData;
|
||||
private EventSystem eventSystem;
|
||||
|
||||
public Transform selectionPoint;
|
||||
|
||||
public static UIManager instance;
|
||||
|
||||
public static UIManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = FindAnyObjectByType<UIManager>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
raycaster = GetComponent<GraphicRaycaster>();
|
||||
eventSystem = GetComponent<EventSystem>();
|
||||
pData = new PointerEventData(eventSystem);
|
||||
|
||||
pData.position = selectionPoint.position;
|
||||
}
|
||||
|
||||
public bool OnEntered(GameObject button)
|
||||
{
|
||||
List<RaycastResult> results = new List<RaycastResult>();
|
||||
raycaster.Raycast(pData, results);
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
if (result.gameObject == button)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UIManager.cs.meta
Normal file
11
Assets/Scripts/UIManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0aac150437f46ae43b6bb6a1e2e7776e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user