This commit is contained in:
Firesieht 2022-01-20 19:45:19 +03:00
parent b122975406
commit ab7bba7c3e
8 changed files with 794 additions and 5010 deletions

File diff suppressed because it is too large Load Diff

View File

@ -76,4 +76,4 @@ MonoBehaviour:
m_AutomaticLoading: 0 m_AutomaticLoading: 0
m_AutomaticRunning: 0 m_AutomaticRunning: 0
m_Loaders: m_Loaders:
- {fileID: 11400000, guid: 3fa5945836eec8f4894e113df7808b3e, type: 2} - {fileID: 11400000, guid: 4edf467f73c5ff0428a1bebff282bc2e, type: 2}

BIN
Assets/images/button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: New Material
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class geometry : MonoBehaviour
{
public bool intersects(float ax, float ay, float ax1, float ay1, float bx, float by, float bx1, float by1)
{
return (ay < by1 || ay1 > by || ax1 < bx || ax > bx1);
}
}

View File

@ -0,0 +1,123 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
using UnityEngine.UI;
using System.Linq;
public class main : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] List<GameObject> chests;
[SerializeField] GameObject chestWidthLamp;
[SerializeField] GameObject button;
ARRaycastManager raycastManager;
Text status;
bool spawnedchest = false;
bool search = true;
public List<ARRaycastHit> hits;
bool isTracking = false; //ýòà ïåðåìåííàÿ state îòñëåæèâàåìîãî ëó÷åì îáúåêòà
GameObject rayRecObj;
void Start()
{
raycastManager = gameObject.GetComponent<ARRaycastManager>();
status = FindObjectOfType<Text>();
}
void Update()
{
detectPLanes();
openChest();
}
private void spawnChests(Vector3 hitPos)
{
List<Vector3> cords = new List<Vector3>{
new Vector3(hitPos.x + 0.7f, hitPos.y, hitPos.z + 0.2f),
new Vector3(hitPos.x - 0.7f, hitPos.y, hitPos.z + 0.2f),
new Vector3(hitPos.x + 0.3f, hitPos.y, hitPos.z + 0.1f),
new Vector3(hitPos.x - 0.3f, hitPos.y, hitPos.z + 0.1f),
new Vector3(hitPos.x , hitPos.y, hitPos.z)
};
for (int i = 0; i <= cords.Count+1; i++) {
GameObject chest = chests[Random.Range(0, chests.Count)];
//GameObject chest = chests[0];
Debug.Log(cords.Count);
int index = Random.Range(0, cords.Count-1);
Instantiate(chest, position: cords[index], rotation: new Quaternion());
cords.RemoveAt(index);
}
Instantiate(chestWidthLamp, position: cords[0], rotation: new Quaternion());
}
private void detectPLanes()
{
hits = new List<ARRaycastHit>();
raycastManager.Raycast(new Vector2(Screen.width / 2, Screen.height / 2), hits, TrackableType.Planes);
if (hits.Count == 0 && search == true)
{
status.text = "Èäåò ïîèñê ïëîñêîñòè" + string.Concat(Enumerable.Repeat(".", Random.RandomRange(1, 3)));
}
else
{
search = false;
if (spawnedchest == false && hits.Count > 0)
{
status.text = "spawned chest";
spawnedchest = true;
spawnChests(hits[0].pose.position);
}
}
}
private void openChest()
{
Ray ray = new Ray(gameObject.transform.GetChild(0).transform.position, gameObject.transform.GetChild(0).transform.forward);
RaycastHit raycastHit;
if (Physics.Raycast(ray, out raycastHit))
{
status.text = "ray";
if (raycastHit.collider.gameObject.tag == "chest")
{
if (isTracking == false)
{
isTracking = true;
rayRecObj = raycastHit.collider.gameObject;
//óñòàíàâëèâàåì ïîäñâåòêó îáúåêòà + äîáàâëÿåì êíîïêó îòêðûòü
rayRecObj.GetComponent<Outline>().enabled = true;
button.SetActive(true);
status.text = "chest";
}
status.text = "chest";
//raycastHit.collider.gameObject.transform.GetChild(0).GetComponent<Renderer>().material.color = Color.green;
}
else
{
resetIsTracking();
}
}
else{
resetIsTracking();
}
}
private void resetIsTracking()
{
if (isTracking == true)
{
isTracking = false;
//ñáðàñûâàåì ïîäñâåòêó îáúåêòà + óáèðàåì êíîïêó îòêðûòü
status.text = "no chest";
rayRecObj.GetComponent<Outline>().enabled = false;
button.SetActive(false);
}
}
}

View File

@ -4,7 +4,10 @@
EditorBuildSettings: EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: [] m_Scenes:
- enabled: 1
path: Assets/Scenes/SampleScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
m_configObjects: m_configObjects:
UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 9c0a239daeaf1f0479e0b8c0c5b5561e, type: 2} UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 6123958850c85ba48a84fa69271a85e5, type: 2}
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 643d2a5baab6e864eba47953f5b8a207, type: 2} com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 5377990f65cc84149b6086468a865dd5, type: 2}

View File

@ -128,7 +128,9 @@ PlayerSettings:
16:9: 1 16:9: 1
Others: 1 Others: 1
bundleVersion: 0.1 bundleVersion: 0.1
preloadedAssets: [] preloadedAssets:
- {fileID: -3562725686151269617, guid: 5377990f65cc84149b6086468a865dd5, type: 2}
- {fileID: 4800000, guid: c9f956787b1d945e7b36e0516201fc76, type: 3}
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 1