In my project I have a game object named “Grandpa” who has multiple children. I assigned Grandpa the following script.
using UnityEngine;
using System.Collections;
public class linechild : MonoBehaviour
{
public string[] kids;
public GameObject Grandpa;
void Start()
{
Grandpa = GameObject.Find("Grandpa");
kids = new string[Grandpa.transform.childCount];
}
void OnGUI()
{
for (int i = 0; i < Grandpa.transform.childCount; i++)
{
kids *= Grandpa.transform.GetChild(i).name;*
//Creates a GUI.Label that increments the Y position down for every increment of i
GUI.Label(new Rect(100, 100 + (i * 30), 200, 20), kids*);*
}
}
}
The script stores all of the children of “Grandpa” in an array and displays their names to the screen using GUI.Label. That looks like this
[73324-array-output-no-line.jpg|73324]_
how can I separate each array item with a line so it would look like this:
_[73325-array-output-with-line.jpg*|73325]*
_*
_*
thanks for the simple answer, this will definitely work! however a UI image will only be visible within a canvas. At least to my knowledge. If I instantiate the image it will do so outside of the canvas rendering them invisible.
– birns92I see is the spawn function much different results wise than what I have here? also yes I guess I meant the projectile I have the enemy prefab under the projectile setting it is spawning them but not exactly how I want
– sid4