AutonomousCars_HDRP/Assets/Scripts/ObjectSelection.cs
2024-11-22 18:02:57 +01:00

100 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Unity.VisualScripting.Metadata;
public class ObjectSelection : MonoBehaviour
{
public GameObject unselectedArrow;
public GameObject selectedArrow;
public GameObject yellowBox;
public GameObject blueBox;
public bool selected = false;
public void selectUnSelectObject()
{
if (selected == false)
{
selected = true;
unselectedArrow.SetActive(false);
selectedArrow.SetActive(true);
yellowBox.SetActive(false);
blueBox.SetActive(true);
}
else if (selected == true)
{
selected = false;
unselectedArrow.SetActive(true);
selectedArrow.SetActive(false);
yellowBox.SetActive(true);
blueBox.SetActive(false);
}
}
}
/* Previous code:
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void selectUnSelectObject(GameObject currentGameObject)
{
foreach (Transform child in currentGameObject.transform)
{
if (child.tag == "selectingSignifier")
{
if(child.gameObject.activeInHierarchy)
{
child.gameObject.SetActive(false);
}
else
{
child.gameObject.SetActive(true);
}
}
}
// List<GameObject> foundObjects = new List<GameObject>();
// GameObject[] allObjects = GameObject.FindObjectsOfType<GameObject>(true);
// foreach (GameObject obj in allObjects)
// {
// if (obj.CompareTag("selectingSignifier"))
// {
// obj.SetActive(true);
// }
// }
}
*/