Ok guys, im prety New to any programing language, and i made this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AnimalSelector
{
public class ChooseAnimal : MonoBehaviour
{
#region Variables
public enum Animals
{
Zebra,
Goat,
Lion
}
public GameObject AnimalSelector;
public Animals animals;
public List<AnimalSetup> animalSetup;
#endregion
#region Calls
private void ShowTextByAnimal(Animals a)
{
foreach (var animal in animalSetup)
{
if (animal.animalType == a)
Debug.Log(animal.text);
}
}
private void CheckKeys()
{
if (Input.GetKey(KeyCode.A))
{
ShowTextByAnimal(Animals.Zebra);
}
else if (Input.GetKey(KeyCode.S))
{
ShowTextByAnimal(Animals.Goat);
}
else if (Input.GetKey(KeyCode.D))
{
ShowTextByAnimal(Animals.Lion);
}
}
#endregion
private void Update()
{
CheckKeys();
}
#region class
[System.Serializable]
public class AnimalSetup
{
public Animals animalType;
public string text;
}
#endregion
}
}
And now i want to make 3 objects that if i press A (Zebra) my object appears
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AnimalSelector;
public class Zebra : MonoBehaviour
{
#region Variables
public GameObject Zebras;
#endregion
void Start()
{
ChooseAnimal = GetComponent<ChooseAnimal>();
Zebras.SetActive(false);
}
// Update is called once per frame
void Update()
{
if(ChooseAnimal.Animals.Zebra)
{
}
}
}
so thats my try, im kinda stuck