Hey guys. I wanted to make a system that added a new gameobject to a list. The specific gameobject is assigned to a gui button in the editor. But every time a press the button in the editor I get an error.
Send help pls
public class DialogNPC : MonoBehaviour
{
public GameObject[] speaker;
public List<Converation> conv;
public Choises[] choises;
int nrOfConv;
bool backAndForth = true;
//private AudioSource[] speakersAudio;
Converation con;
public void makeConvForSpeaker(GameObject speaker)
{
con.who = speaker;
conv.Add(con);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(DialogNPC))]
public class DialogSystemEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
DialogNPC npc = (DialogNPC)target;
for (int i = 0; i < npc.speaker.Length; i++)
if (GUILayout.Button(npc.speaker[i].name))
npc.makeConvForSpeaker(npc.speaker[i]);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Converation : MonoBehaviour
{
public string theLine;
public GameObject who;
public AudioClip audio;
}