Question by 
               NoobTaco · May 04, 2016 at 03:14 AM · 
                c#uiscroll view  
              
 
              Scroll View Children not Behaving (UI Instantiated Prefabs not conforming to guide)
I am having one heck of a time getting my UI prefabs for a scroll view list to keep their formatting. I am sure it's something simple I am over looking but could use some fresh eyes and some guidance.
I am including 2 screenshots of what it is doing, as well as the layout in the editor and what components I have on it. I am also going to list my code.
The top line is a prefab just placed on the container. The rest are rendered by the array.
I appreciate any help I can get.
Thanks


 using UnityEngine;
 using UnityEngine.UI;
 using System.IO;
 
 
 
 public class FileListCharacter : MonoBehaviour
 {
     public UMAMakerOne _umaMakerOne;
 
     public GameObject button;
 
     // Use this for initialization
     void Start()
     {
         DirectoryInfo dir = new DirectoryInfo("Assets/Characters");
         FileInfo[] fileNames = dir.GetFiles("*.txt");
         foreach (FileInfo f in fileNames)
         {
             Debug.Log(f);
             var fName = Path.GetFileNameWithoutExtension(f.ToString());
             var fNameTrim = fName.Replace("_UMA_Recipe", "");
             GameObject fileList = GameObject.Find("CharacterScrollView/Viewport/Content");
             GameObject newButton = Instantiate(button) as GameObject;
             newButton.transform.SetParent(fileList.transform);
             newButton.GetComponentInChildren<Text>().text = fNameTrim;
             newButton.GetComponent<Button>().onClick.AddListener(() => { _umaMakerOne.Load(); });
         }
     }
 }
 
               
                 
                viewlist.png 
                (16.3 kB) 
               
 
                
                 
                viewlist4.png 
                (49.7 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
InputField remove one character 2 Answers
Error CS1061: Are you missing an assembly reference? 2 Answers
Delayed jump on android 1 Answer