Search Unity

Resolved EditorGUILayout.BeginVertical(); not create a case.

Discussion in 'Editor & General Support' started by maxime66410, Jan 18, 2020.

  1. maxime66410

    maxime66410

    Joined:
    Mar 16, 2018
    Posts:
    19
    Hello, For some time I have been developing an FNAF game, but I am stuck in a very annoying part for the rest of my development.



    normally when i want to put what i want to do that should do that to me :


    But instead it makes me an empty box :c



    I provide you with the code lines to help me resolve this error.


    Thanks for all the people trying to help me

    Animatronic.cs
    Code (CSharp):
    1.  
    2.     using System.Collections;
    3.     using System.Collections.Generic;
    4.     using UnityEngine;
    5.  
    6.     public class Animatronic : MonoBehaviour
    7.     {
    8.         [System.Serializable]
    9.         public enum Actions
    10.         {
    11.             TPose = 0,
    12.             Stage,
    13.             Standing,
    14.             OutsideCamera,
    15.             OusideWindow,
    16.             OutSideDoor,
    17.             Kill
    18.         }
    19.  
    20.         [System.Serializable]
    21.         public struct AnimatronicNodeData
    22.         {
    23.             public Node node;
    24.             public bool weight;
    25.             public Actions action;
    26.         }
    27.  
    28.         public Node startLocation;
    29.  
    30.         public AnimatronicNodeData[] nodeData;
    31.  
    32.         // Start is called before the first frame update
    33.         void Start()
    34.         {
    35.             this.gameObject.transform.position = startLocation.gameObject.transform.position;
    36.             this.gameObject.transform.rotation = startLocation.gameObject.transform.rotation;
    37.         }
    38.  
    39.         // Update is called once per frame
    40.         void Update()
    41.         {
    42.          
    43.         }
    44.     }
    45.    

    AnimatronicEditor.cs
    Code (CSharp):
    1.  
    2.     using System.Collections;
    3.     using UnityEngine;
    4.     using UnityEditor;
    5.  
    6.     [CustomEditor(typeof(Animatronic))]
    7.     public class AnimatronicEditor : Editor
    8.     {
    9.  
    10.         public override void OnInspectorGUI()
    11.         {
    12.             Animatronic animatronicScript = (Animatronic)target;
    13.  
    14.             animatronicScript.startLocation = (Node) EditorGUILayout.ObjectField("Starting Node:", animatronicScript.startLocation, typeof(Node), true);
    15.  
    16.             IAManager[] aiManager = Resources.FindObjectsOfTypeAll<IAManager>();
    17.  
    18.  
    19.             if (aiManager == null)
    20.             {
    21.                 EditorGUILayout.HelpBox("Scene must have and AI Manager to populate Nodes.", MessageType.Error);
    22.             }
    23.  
    24.             else
    25.             {
    26.                 Node[] nodes = aiManager[0].nodes;
    27.  
    28.                 if(animatronicScript.nodeData == null || animatronicScript.nodeData.Length != nodes.Length)
    29.                 {
    30.                     animatronicScript.nodeData = new Animatronic.AnimatronicNodeData[nodes.Length];
    31.                     for(int i = 0; i < nodes.Length; i++)
    32.                     {
    33.                         animatronicScript.nodeData[i] = new Animatronic.AnimatronicNodeData();
    34.                     }
    35.                 }
    36.  
    37.                 EditorGUILayout.BeginVertical();
    38.  
    39.                 for(int i = 0; i < nodes.Length; i++)
    40.                 {
    41.                     EditorGUILayout.BeginHorizontal();
    42.  
    43.                     EditorGUILayout.TextArea(nodes[i].name);
    44.  
    45.                     animatronicScript.nodeData[i].action = (Animatronic.Actions)EditorGUILayout.EnumPopup(animatronicScript.nodeData[i].action);
    46.                     animatronicScript.nodeData[i].weight = EditorGUILayout.Toggle(animatronicScript.nodeData[i].weight);
    47.  
    48.                     EditorGUILayout.EndHorizontal();
    49.                 }
    50.  
    51.                 EditorGUILayout.EndVertical();
    52.             }
    53.         }
    54.     }
    55.    
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Could it be that there are 0 nodes in the aiManager?
     
  3. maxime66410

    maxime66410

    Joined:
    Mar 16, 2018
    Posts:
    19
    Yet usually when I do that, it puts me that

    this :



    BUT I can't do anything since it goes like this
     
  4. maxime66410

    maxime66410

    Joined:
    Mar 16, 2018
    Posts:
    19
    problem solved, in fact seen as I am French we say IA, but seen as in English I am told backwards I just put AI.

    resolution :

    Change IAManager -> AIManager