public virtual void OnGUI(Rect rect) { if (this.data != null) { var dataType = GUILayoutExt.GetTypeLabel(this.data.GetType()); GUI.Label(rect, dataType, Styles.nodeCaption); } }
private void DrawEntities(WorldEditor world) { var style = EditorStyles.helpBox; this.scrollEntitiesPosition = GUILayout.BeginScrollView(this.scrollEntitiesPosition, style, GUILayout.ExpandHeight(true)); { if (world == null) { var centeredStyle = new GUIStyle(EditorStyles.centeredGreyMiniLabel); centeredStyle.stretchHeight = true; centeredStyle.richText = true; GUILayout.Label("Select world from the left list.", centeredStyle); } else { var padding = 2f; var margin = 1f; var dataStyle = new GUIStyle(EditorStyles.label); dataStyle.richText = true; dataStyle.wordWrap = true; var modules = world.GetModules(); //var componentsStorage = world.GetComponentsStorage(); var entitiesStorage = world.GetEntitiesStorage(); foreach (var entityStorage in entitiesStorage) { if (entityStorage == null) { continue; } var storages = entityStorage.Cast <ME.ECS.IStorage>().ToList(); foreach (var storage in storages) { if (storage == null) { continue; } GUILayout.BeginVertical(); { var foldout = world.IsFoldOut(storage); GUILayoutExt.FoldOut(ref foldout, GUILayoutExt.GetTypeLabel(storage.GetType()), () => { var list = storage.GetData(); for (var i = list.FromIndex; i < list.SizeCount; ++i) { if (list.IsFree(i) == true) { continue; } var item = list.Get <ME.ECS.IEntity>(i); var entityData = item; GUILayoutExt.Box( padding, margin, () => { GUILayout.Space(2f); GUILayout.Label("Entity " + entityData.entity.id.ToString() + " (" + entityData.entity.storageIdx.ToString() + ")"); GUILayoutExt.Box( padding, margin, () => { #region Data var foldoutData = world.IsFoldOutData(storage, entityData.entity.id); GUILayoutExt.FoldOut(ref foldoutData, "Data", () => { { // Draw data table GUILayoutExt.DrawFields(item, 120f); } }); world.SetFoldOutData(storage, entityData.entity.id, foldoutData); #endregion #region Components var foldoutComponents = world.IsFoldOutComponents(storage, entityData.entity.id); GUILayoutExt.FoldOut(ref foldoutComponents, "Components", () => { GUILayout.Label("Due to technical issues components list is not supported for now", EditorStyles.miniBoldLabel); /*ME.ECS.IComponentsBase components; * if (componentsStorage.TryGetValue(entityData.entity.id, out components) == true) { * * var componentsDic = components.GetData(entityData.entity.id); * foreach (var component in componentsDic) { * * GUILayoutExt.Box( * padding, * margin, * () => { * * GUILayout.Space(2f); * GUILayout.BeginHorizontal(); * GUILayout.Label(component.GetType().Name, GUILayout.Width(90f)); * GUILayoutExt.TypeLabel(component.GetType()); * GUILayout.EndHorizontal(); * * GUILayoutExt.Box( * padding, * margin, * () => { * * GUILayout.Label("Data", EditorStyles.miniBoldLabel); * GUILayoutExt.DrawFields(component, 120f); * * }, GUIStyle.none); * * }, "dragtabdropwindow"); * * } * * }*/ }); world.SetFoldOutComponents(storage, entityData.entity.id, foldoutComponents); #endregion #if VIEWS_MODULE_SUPPORT var foldoutViews = world.IsFoldOutViews(storage, entityData.entity.id); GUILayoutExt.FoldOut(ref foldoutViews, "Views", () => { { // Draw views table var viewsModules = modules.OfType <ME.ECS.Views.IViewModuleBase>().ToArray(); foreach (var viewsModule in viewsModules) { if (viewsModule != null) { var allViews = viewsModule.GetData(); foreach (DictionaryEntry itemEntry in allViews) { var key = (EntityId)itemEntry.Key; if (key == entityData.entity.id) { var listViews = (IList)itemEntry.Value; for (int j = 0; j < listViews.Count; ++j) { var view = (ME.ECS.Views.IViewBase)listViews[j]; GUILayoutExt.Box( padding, margin, () => { GUILayout.Label("Prefab Source Id: " + view.prefabSourceId.ToString()); var provider = viewsModule.GetViewSourceProvider(view.prefabSourceId); GUILayout.Label("Provider: " + GUILayoutExt.GetTypeLabel(provider.GetType())); GUILayout.Label("Creation Tick: " + view.creationTick.ToString()); }); } } } } } } }); world.SetFoldOutViews(storage, entityData.entity.id, foldoutViews); #endif }, GUIStyle.none); }, "dragtabdropwindow"); list.Set(i, entityData); } }); world.SetFoldOut(storage, foldout); } GUILayout.EndVertical(); } } } } GUILayout.EndScrollView(); }
public static void TypeLabel(System.Type type, params GUILayoutOption[] options) { GUILayoutExt.DataLabel(GUILayoutExt.GetTypeLabel(type), options); }
public override void OnGUI(Rect rect) { var dataType = GUILayoutExt.GetTypeLabel(this.GetType()); GUI.Label(rect, dataType, Styles.containerCaption); }