Пример #1
0
        void DrawTypeField(object instance, FieldInfo field, EcsEntityObserver entity)
        {
            var fieldValue = field.GetValue(instance);
            var fieldType  = field.FieldType;

            if (!EcsComponentInspectors.Render(field.Name, fieldType, fieldValue, entity))
            {
                if (fieldType == typeof(UnityEngine.Object) || fieldType.IsSubclassOf(typeof(UnityEngine.Object)))
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(field.Name, GUILayout.MaxWidth(EditorGUIUtility.labelWidth - 16));
                    var guiEnabled = GUI.enabled;
                    GUI.enabled = false;
                    EditorGUILayout.ObjectField(fieldValue as UnityEngine.Object, fieldType, false);
                    GUI.enabled = guiEnabled;
                    GUILayout.EndHorizontal();
                    return;
                }
                var strVal = fieldValue != null?string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", fieldValue) : "null";

                if (strVal.Length > MaxFieldToStringLength)
                {
                    strVal = strVal.Substring(0, MaxFieldToStringLength);
                }
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(field.Name, GUILayout.MaxWidth(EditorGUIUtility.labelWidth - 16));
                EditorGUILayout.SelectableLabel(strVal, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight));
                GUILayout.EndHorizontal();
            }
        }
Пример #2
0
        void DrawComponents()
        {
            var count = _entity.World.GetComponents(_entity.Id, ref _componentsCache);

            for (var i = 0; i < count; i++)
            {
                var component = _componentsCache[i];
                _componentsCache[i] = null;
                var type = component.GetType();
                GUILayout.BeginVertical(GUI.skin.box);
                if (!EcsComponentInspectors.Render(type.Name, type, component, _entity))
                {
                    EditorGUILayout.LabelField(type.Name, EditorStyles.boldLabel);
                    var indent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel++;
                    foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                    {
                        DrawTypeField(component, field, _entity);
                    }
                    EditorGUI.indentLevel = indent;
                }
                GUILayout.EndVertical();
                EditorGUILayout.Space();
            }
        }
Пример #3
0
 void DrawComponents()
 {
     if (_observer.gameObject.activeSelf)
     {
         var count = _observer.Entity.IsAlive() ? _observer.Entity.GetComponentValues(ref _componentsCache) : 0;
         for (var i = 0; i < count; i++)
         {
             var component = _componentsCache[i];
             _componentsCache[i] = null;
             var type = component.GetType();
             GUILayout.BeginVertical(GUI.skin.box);
             var typeName = EditorHelpers.GetCleanGenericTypeName(type);
             if (!EcsComponentInspectors.Render(typeName, type, component, _observer))
             {
                 EditorGUILayout.LabelField(typeName, EditorStyles.boldLabel);
                 var indent = EditorGUI.indentLevel;
                 EditorGUI.indentLevel++;
                 foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public))
                 {
                     DrawTypeField(component, field, _observer);
                 }
                 EditorGUI.indentLevel = indent;
             }
             GUILayout.EndVertical();
             EditorGUILayout.Space();
         }
     }
 }
Пример #4
0
        void DrawTypeField(object instance, FieldInfo field)
        {
            var fieldValue = field.GetValue(instance);
            var fieldType  = field.FieldType;

            if (!EcsComponentInspectors.Render(field.Name, fieldType, fieldValue))
            {
                if (fieldType == typeof(UnityEngine.Object) || fieldType.IsSubclassOf(typeof(UnityEngine.Object)))
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(field.Name, GUILayout.MaxWidth(EditorGUIUtility.labelWidth - 16));
                    var guiEnabled = GUI.enabled;
                    GUI.enabled = false;
                    EditorGUILayout.ObjectField(fieldValue as UnityEngine.Object, fieldType, false);
                    GUI.enabled = guiEnabled;
                    GUILayout.EndHorizontal();
                    return;
                }
                var strVal = fieldValue != null?string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", fieldValue) : "null";

                EditorGUILayout.TextField(field.Name, strVal);
            }
        }