gun elements added and uvs updated to better space out texture.
This commit is contained in:
58
Assets/Scripts/Interactable/ItemSelector.cs
Normal file
58
Assets/Scripts/Interactable/ItemSelector.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemSelector : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Camera cam;
|
||||
private InteractableItem selected;
|
||||
[SerializeField]
|
||||
private bool debug = false;
|
||||
[SerializeField]
|
||||
private LayerMask mask;
|
||||
public static ItemSelector instance;
|
||||
[SerializeField]
|
||||
private float range = 1;
|
||||
|
||||
public InteractableItem Selected { get { return selected; } }
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit,range,layerMask:mask))
|
||||
{
|
||||
if(selected!= null||hit.transform.gameObject==null)
|
||||
{
|
||||
selected.Disable();
|
||||
}
|
||||
|
||||
selected = hit.transform.gameObject.GetComponent<InteractableItem>();
|
||||
selected.Enable();
|
||||
print(selected);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selected != null)
|
||||
{
|
||||
selected.Disable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Interactable/ItemSelector.cs.meta
Normal file
11
Assets/Scripts/Interactable/ItemSelector.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eb8c70704eba0741a0b281bc6ff3d8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user