public Texture icon;public string text;public bool showingContent;public List<Title> parent = new List<Title>(); public List<Title> menuList = new List<Title>();public List<Content> contentList = new List<Content>();
void CreateTitle(Title title){ GameObject parent = new GameObject(); GameObject icon = new GameObject(); GameObject back = new GameObject(); GameObject text = new GameObject(); menuManager.gameObjecsInScene.Add(parent); icon.transform.parent = parent.transform; text.transform.parent = parent.transform; back.transform.parent = parent.transform; parent.transform.parent = menuManager.tk2DScrollableAreaContent.transform; icon.name = "Icon"; text.name = "Title"; back.name = "Back"; parent.name = title.text + " title"; parent.transform.localPosition = Vector3.zero; back.transform.localPosition = Vector3.zero; icon.transform.localPosition = new Vector3(-16, 0, 0); text.transform.localPosition = new Vector3(-12, 0, 0); tk2dTextMesh textMesh = text.AddComponent<tk2dTextMesh>(); textMesh.anchor = TextAnchor.MiddleLeft; textMesh.text = title.text; textMesh.maxChars = 50; textMesh.scale = Vector3.one * 15; textMesh.Commit(); }
NullReferenceException: Object reference not set to an instance of an objecttk2dTextMesh.Commit () (at Assets/TK2DROOT/tk2d/Code/Fonts/tk2dTextMesh.cs:540)MenuManagerEditor.CreateTitle (.Title title) (at Assets/Editor/MenuManagerEditor.cs:143)MenuManagerEditor.CommitMenu () (at Assets/Editor/MenuManagerEditor.cs:110)MenuManagerEditor.OnInspectorGUI () (at Assets/Editor/MenuManagerEditor.cs:34)UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/Mono/Inspector/InspectorWindow.cs:888)UnityEditor.DockArea:OnGUI()