- Home /
Issues when hooking GUI to code
Hello, I've run into two problems while making a GUI which I can't figure out despite wrestling with the Unity API and looking through questions:
The first problem is that I'm trying to dynamically add buttons with a name and a text content from two lists of strings in another C# namespace (let's call them RT.ObjectNameList
and RT.TextContentList
), but despite looking at https://unity3d.com/learn/tutorials/topics/user-interface-ui/adding-buttons-script?playlist=17111 I haven't got this working. I have found a way to make the viewport content object size with the content though. The buttons I'm using here are text fields with a button component.
My second problem boils down to me not knowing how to get scripts working from a UnityEvent (button On Click
, input field On Value Changed
, etc): where to add the script components, what to listen for, and how to do the syntax correctly. Specifically, I'm trying to filter the TextContentList based on the input field, and get the scroll view buttons to copy their text content to <selected target>
and RT.SelectedTarget
when pressed. The filter code won't be a problem, I'm just struggling with the unity way of doing things. I'm using the 2017.1.3p1 version if that helps.
TL;DR:
How do I add gameobjects based on two lists in a different .cs and namespace?
How do I move variables between scripts (please be detailed)?
I have figured out the second problem by making them static, still not sure about the first one.
Your answer
![](https://koobas.hobune.stream/wayback/20220612201752im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do you CORRECTLY call methods from another C# file 1 Answer
When does Drop UI event get called? 0 Answers
ExecuteEvents.Execute pass object to from ui 1 Answer
When I pause my game and enable canvas and then resume my keyboard starts controlling the menu... 1 Answer