void CreateUIGrid(PatternBuilder builder) { //Debug.Log("Creating UI Grid..."); jg = builder.GetGrid(); /*if (grid) * { * foreach(var item in popupOptions) * Debug.Log(item); * foreach (var item in indexes) * Debug.Log(item.ToString()); * }*/ Repaint(); //Debug.Log(jg.ToString()); GUILayout.Label("Pattern", EditorStyles.boldLabel); /*if(jg == null || popupOptions == null || indexes == null) * { * if(jg == null) * Debug.Log("Grid is null."); * if (popupOptions == null) * Debug.Log("Popup Options are null."); * if(indexes == null) * Debug.Log("Indexes are null."); * }*/ if (jg != null && _popupOptions != null && indexes != null) { for (int i = 0; i < jg.GetIndexes().GetLength(0); i++) //rows { EditorGUILayout.BeginHorizontal(); for (int j = 0; j < jg.GetIndexes().GetLength(1); j++) //columns { EditorGUILayout.BeginVertical(); indexes[i, j] = EditorGUILayout.Popup(indexes[i, j], _popupOptions); EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } } if (GUILayout.Button("Set")) { PatternByUI(builder); } EditorGUILayout.Space(); }
/// <summary> /// Display grid layout in scene view /// </summary> void OnDrawGizmos() { Gizmos.color = Color.yellow; if (jkg == null) { return; } foreach (var element in jkg.GetIndexes()) { Gizmos.DrawSphere(element.Item2, .25f); } //Horizontal Gizmos.DrawLine(new Vector3(jkg.GetWorldPos().x - .5f * jkg.GetSize(), jkg.GetWorldPos().y + .5f * jkg.GetSize()), new Vector3(jkg.GetWorldPos().x + .5f * jkg.GetSize(), jkg.GetWorldPos().y + .5f * jkg.GetSize())); Gizmos.DrawLine(new Vector3(jkg.GetWorldPos().x - .5f * jkg.GetSize(), jkg.GetWorldPos().y - .5f * jkg.GetSize()), new Vector3(jkg.GetWorldPos().x + .5f * jkg.GetSize(), jkg.GetWorldPos().y - .5f * jkg.GetSize())); //Vertical Gizmos.DrawLine(new Vector3(jkg.GetWorldPos().x - .5f * jkg.GetSize(), jkg.GetWorldPos().y + .5f * jkg.GetSize()), new Vector3(jkg.GetWorldPos().x - .5f * jkg.GetSize(), jkg.GetWorldPos().y - .5f * jkg.GetSize())); Gizmos.DrawLine(new Vector3(jkg.GetWorldPos().x + .5f * jkg.GetSize(), jkg.GetWorldPos().y + .5f * jkg.GetSize()), new Vector3(jkg.GetWorldPos().x + .5f * jkg.GetSize(), jkg.GetWorldPos().y - .5f * jkg.GetSize())); }