Files
plugin-library/Assets/Plugins/Sirenix/Odin Inspector/Modules/Unity.Entities.data

968 lines
41 KiB
Plaintext
Raw Normal View History

2025-03-31 10:10:35 +08:00
/MSirenix.OdinInspector.Editor.Modules.ModuleData, Sirenix.OdinInspector.Editor'IDUnity.EntitiesVersion/System.Version, mscorlibFiles/<01>System.Collections.Generic.List`1[[Sirenix.OdinInspector.Editor.Modules.ModuleData+ModuleFile, Sirenix.OdinInspector.Editor]], mscorlib/XSirenix.OdinInspector.Editor.Modules.ModuleData+ModuleFile, Sirenix.OdinInspector.Editor'PathAABBAttributeProcessor.csData/System.Byte[], mscorlib<08>//-----------------------------------------------------------------------
// <copyright file="AABBAttributeProcessor.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector.Editor;
using System.Reflection;
using Unity.Mathematics;
public class AABBAttributeProcessor : OdinAttributeProcessor<AABB>
{
public override bool CanProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member)
{
return false;
}
public override void ProcessSelfAttributes(InspectorProperty property, List<Attribute> attributes)
{
attributes.GetOrAddAttribute<InlinePropertyAttribute>();
}
}
}
0'PathAABBAttributeProcessor.cs.metaData0<08>fileFormatVersion: 2
guid: 99aec795f53d8e143a1d7f42bcc5b17b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'PathBufferElementDataWrapper.csData0<08>//-----------------------------------------------------------------------
// <copyright file="BufferElementDataWrapper.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using Unity.Entities;
public struct BufferElementDataWrapper<T> where T : struct, IBufferElementData
{
[ShowInInspector, LabelText("Dynamic Buffer Contents"), ListDrawerSettings(HideAddButton = true, HideRemoveButton = true, DraggableItems = false, Expanded = true)]
public DynamicBuffer<T> Buffer;
}
}
0 'Path BufferElementDataWrapper.cs.metaData0
<08>fileFormatVersion: 2
guid: 565c74c49444ab740bd725bfb0d6c1b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0 'Path!BufferElementDataWrapperDrawer.csData0 {//-----------------------------------------------------------------------
// <copyright file="BufferElementDataWrapperDrawer.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using Sirenix.Utilities.Editor;
public class BufferElementDataWrapperDrawer<TBufferElementData> : OdinValueDrawer<BufferElementDataWrapper<TBufferElementData>>
where TBufferElementData : struct, IBufferElementData
{
protected override void DrawPropertyLayout(GUIContent label)
{
var rect = OdinECSEditorGUI.HeaderLabel(typeof(TBufferElementData).FullName, OdinECSEditorGUI.EntityIcon, this.Property.Children.Count > 0);
GUI.Label(rect, "Buffer Element Data", SirenixGUIStyles.RightAlignedGreyMiniLabel);
this.CallNextDrawer(null);
OdinECSEditorGUI.DrawVerticalInspectorSeparator();
}
}
}
0 'Path&BufferElementDataWrapperDrawer.cs.metaData0<08>fileFormatVersion: 2
guid: 670d7bc249ee5584c90508555cbe66e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'Path"DynamicBufferCollectionResolver.csData0<08>//-----------------------------------------------------------------------
// <copyright file="DynamicBufferCollectionResolver.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
using System.Collections.Generic;
using System.Linq;
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities.Editor;
public class DynamicBufferCollectionResolver<T> : BaseOrderedCollectionResolver<DynamicBuffer<T>> where T : struct
{
private static readonly EqualityComparer<T> ElementComparer = EqualityComparer<T>.Default;
private Dictionary<int, InspectorPropertyInfo> childInfos = new Dictionary<int, InspectorPropertyInfo>();
public override Type ElementType { get { return typeof(T); } }
public override InspectorPropertyInfo GetChildInfo(int childIndex)
{
if (childIndex < 0 || childIndex >= this.ChildCount)
{
throw new IndexOutOfRangeException();
}
InspectorPropertyInfo result;
if (!this.childInfos.TryGetValue(childIndex, out result))
{
result = InspectorPropertyInfo.CreateValue(
name: CollectionResolverUtilities.DefaultIndexToChildName(childIndex),
order: childIndex,
serializationBackend: this.Property.BaseValueEntry.SerializationBackend,
getterSetter: new GetterSetter<DynamicBuffer<T>, T>(
getter: (ref DynamicBuffer<T> list) => list[childIndex],
setter: (ref DynamicBuffer<T> list, T element) => list[childIndex] = element),
attributes: this.Property.Attributes.Where(attr => !attr.GetType().IsDefined(typeof(DontApplyToListElementsAttribute), true)).Append(new EnableGUIAttribute()).ToArray());
this.childInfos[childIndex] = result;
}
return result;
}
public override bool ChildPropertyRequiresRefresh(int index, InspectorPropertyInfo info)
{
return false;
}
public override int ChildNameToIndex(string name)
{
return CollectionResolverUtilities.DefaultChildNameToIndex(name);
}
public override int ChildNameToIndex(ref StringSlice name)
{
return CollectionResolverUtilities.DefaultChildNameToIndex(ref name);
}
protected override int GetChildCount(DynamicBuffer<T> value)
{
if (!value.IsCreated) return 0;
return value.Length;
}
protected override void Add(DynamicBuffer<T> collection, object value)
{
if (!collection.IsCreated) return;
collection.Add((T)value);
}
protected override void InsertAt(DynamicBuffer<T> collection, int index, object value)
{
if (!collection.IsCreated) return;
collection.Insert(index, (T)value);
}
protected override void Remove(DynamicBuffer<T> collection, object value)
{
if (!collection.IsCreated) return;
T val = (T)value;
for (int i = 0; i < collection.Length; i++)
{
if (ElementComparer.Equals(collection[i], val))
{
collection.RemoveAt(i);
return;
}
}
}
protected override void RemoveAt(DynamicBuffer<T> collection, int index)
{
if (!collection.IsCreated) return;
collection.RemoveAt(index);
}
protected override void Clear(DynamicBuffer<T> collection)
{
if (!collection.IsCreated) return;
collection.Clear();
}
protected override bool CollectionIsReadOnly(DynamicBuffer<T> collection)
{
// Let's... not edit this, perhaps?
return false;
}
}
}
0'Path'DynamicBufferCollectionResolver.cs.metaData0<08>fileFormatVersion: 2
guid: 4112ab7873dc6c04495d3ed9aa3b0cc6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'PathEntityAttributeProcessor.csData0<08>//-----------------------------------------------------------------------
// <copyright file="EntityAttributeProcessor.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
using System.Collections.Generic;
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using System.Reflection;
public class EntityAttributeProcessor : OdinAttributeProcessor<Entity>
{
public override bool CanProcessChildMemberAttributes(InspectorProperty parentProperty, MemberInfo member)
{
return false;
}
public override void ProcessSelfAttributes(InspectorProperty property, List<Attribute> attributes)
{
attributes.GetOrAddAttribute<InlinePropertyAttribute>();
}
}
}
0'Path EntityAttributeProcessor.cs.metaData0<08>fileFormatVersion: 2
guid: 583a30f7f1c035640ab8da4ea54837ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'PathEntityComponentDataDrawer.csData0<08>//-----------------------------------------------------------------------
// <copyright file="EntityComponentDataDrawer.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
public class EntityComponentDataDrawer<T> : OdinValueDrawer<T> where T : struct, IComponentData
{
protected override void DrawPropertyLayout(GUIContent label)
{
OdinECSEditorGUI.HeaderLabel(typeof(T).FullName, OdinECSEditorGUI.EntityIcon, this.Property.Children.Count > 0);
for (int i = 0; i < this.Property.Children.Count; i++)
{
this.Property.Children[i].Draw();
}
OdinECSEditorGUI.DrawVerticalInspectorSeparator();
}
}
}
0'Path!EntityComponentDataDrawer.cs.metaData0<08>fileFormatVersion: 2
guid: 9541f027d65b0cc439d9802cf7dd3a7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'PathEntityInspectionData.csData0 //-----------------------------------------------------------------------
// <copyright file="EntitySelectionProxyPropertyProcessor.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using Unity.Entities;
public class EntityInspectionData
{
public Entity Entity;
public EntityManager EntityManager;
}
}
0'PathEntityInspectionData.cs.metaData0<08>fileFormatVersion: 2
guid: f7edf656bab5bc641a0a4677dbcbc4e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0'Path"EntityManagedComponentAttribute.csData0 <08>//-----------------------------------------------------------------------
// <copyright file="EntityManagedComponentAttribute.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
[AttributeUsage(AttributeTargets.All)]
public class EntityManagedComponentAttribute : Attribute
{
}
}
0!'Path'EntityManagedComponentAttribute.cs.metaData0"<08>fileFormatVersion: 2
guid: 92700f432a2fa8c4f94cb50b35e12818
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0#'Path(EntityManagedComponentAttributeDrawer.csData0$<08>//-----------------------------------------------------------------------
// <copyright file="EntityManagedComponentAttributeDrawer.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using UnityEditor;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using Sirenix.Utilities.Editor;
[DrawerPriority(0.51, 0, 0)]
public class EntityManagedComponentAttributeDrawer<T> : OdinAttributeDrawer<EntityManagedComponentAttribute, T> where T : Component
{
protected override void DrawPropertyLayout(GUIContent label)
{
var drawComponent = this.ValueEntry.ValueState != PropertyValueState.NullReference;
var rect = OdinECSEditorGUI.HeaderLabel(typeof(T).FullName, GUIHelper.GetAssetThumbnail(this.ValueEntry.SmartValue, this.ValueEntry.BaseValueType, false), drawComponent);
if (drawComponent)
{
GUIHelper.PushGUIEnabled(false);
rect.xMin += EditorGUIUtility.labelWidth;
SirenixEditorFields.UnityObjectField(rect, this.ValueEntry.SmartValue, this.ValueEntry.BaseValueType, false);
GUIHelper.PopGUIEnabled();
this.CallNextDrawer(null);
}
OdinECSEditorGUI.DrawVerticalInspectorSeparator();
}
}
}
0%'Path-EntityManagedComponentAttributeDrawer.cs.metaData0&<08>fileFormatVersion: 2
guid: 338b5e02d8311534e9e8ce3b0375eb36
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0''PathEntityPropertyResolver.csData0((//-----------------------------------------------------------------------
// <copyright file="EntityPropertyResolver.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
using System.Collections.Generic;
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using System.Reflection;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
public class EntityPropertyResolver : OdinPropertyResolver<EntityInspectionData>, IRefreshableResolver
{
private static readonly MethodInfo CreateComponentDataGetterSetter_Method = typeof(EntityPropertyResolver).GetMethod("CreateComponentDataGetterSetter", Flags.StaticAnyVisibility);
private static readonly MethodInfo CreateSharedComponentDataGetterSetter_Method = typeof(EntityPropertyResolver).GetMethod("CreateSharedComponentDataGetterSetter", Flags.StaticAnyVisibility);
private static readonly MethodInfo CreateUnityObjectComponentGetterSetter_Method = typeof(EntityPropertyResolver).GetMethod("CreateUnityObjectComponentGetterSetter", Flags.StaticAnyVisibility);
private static readonly MethodInfo CreateBufferElementDataGetterSetter_Method = typeof(EntityPropertyResolver).GetMethod("CreateBufferElementDataGetterSetter", Flags.StaticAnyVisibility);
private Dictionary<int, InspectorPropertyInfo> infos = new Dictionary<int, InspectorPropertyInfo>();
private static readonly Dictionary<Type, Type> ExpectedTypeMapping = new Dictionary<Type, Type>(FastTypeComparer.Instance);
public override int ChildNameToIndex(string name)
{
return CollectionResolverUtilities.DefaultChildNameToIndex(name);
}
public override int ChildNameToIndex(ref StringSlice name)
{
return CollectionResolverUtilities.DefaultChildNameToIndex(ref name);
}
public override InspectorPropertyInfo GetChildInfo(int childIndex)
{
InspectorPropertyInfo result;
if (!this.infos.TryGetValue(childIndex, out result))
{
var data = this.ValueEntry.SmartValue;
ComponentType componentType;
Type type;
using (var types = data.EntityManager.GetComponentTypes(data.Entity))
{
componentType = types[childIndex];
type = componentType.GetManagedType();
}
IValueGetterSetter getterSetter;
bool isComponentData = type.IsValueType && typeof(IComponentData).IsAssignableFrom(type);
bool isSharedComponentData = type.IsValueType && typeof(ISharedComponentData).IsAssignableFrom(type);
bool isUnityObjectComponent = !isComponentData && !isSharedComponentData && typeof(Component).IsAssignableFrom(type);
bool isBufferElementData = !isComponentData && !isSharedComponentData && !isUnityObjectComponent && type.IsValueType && typeof(IBufferElementData).IsAssignableFrom(type);
// This rather horrid and inefficient reflection approach is merely temporary - API's to solve this problem in a faster and easier way are coming to Odin soon
if (isComponentData)
{
getterSetter = (IValueGetterSetter)CreateComponentDataGetterSetter_Method.MakeGenericMethod(type).Invoke(null, new object[] { componentType });
}
else if (isSharedComponentData)
{
getterSetter = (IValueGetterSetter)CreateSharedComponentDataGetterSetter_Method.MakeGenericMethod(type).Invoke(null, new object[] { componentType });
}
else if (isUnityObjectComponent)
{
getterSetter = (IValueGetterSetter)CreateUnityObjectComponentGetterSetter_Method.MakeGenericMethod(type).Invoke(null, new object[] { componentType });
}
else if (isBufferElementData)
{
getterSetter = (IValueGetterSetter)CreateBufferElementDataGetterSetter_Method.MakeGenericMethod(type).Invoke(null, new object[] { componentType });
}
else
{
throw new NotImplementedException("Missing support for putting " + type.GetNiceFullName() + " on entities.");
}
result = InspectorPropertyInfo.CreateValue(
CollectionResolverUtilities.DefaultIndexToChildName(childIndex),
0, SerializationBackend.None,
getterSetter);
if (isUnityObjectComponent)
{
var attrs = result.GetEditableAttributesList();
attrs.Add(new InlineEditorAttribute(InlineEditorObjectFieldModes.CompletelyHidden));
attrs.Add(new EntityManagedComponentAttribute());
}
this.infos.Add(childIndex, result);
}
return result;
}
protected override int GetChildCount(EntityInspectionData value)
{
return value.EntityManager.GetComponentCount(value.Entity);
}
private static IValueGetterSetter CreateComponentDataGetterSetter<T>(ComponentType componentType) where T : struct, IComponentData
{
int typeIndex = TypeManager.GetTypeIndex<T>();
bool zeroSized = ComponentType.FromTypeIndex(typeIndex).IsZeroSized;
return new GetterSetter<EntityInspectionData, T>(
getter: (ref EntityInspectionData data) =>
{
if (zeroSized) return default(T);
if (data.EntityManager.HasComponent<T>(data.Entity))
return data.EntityManager.GetComponentData<T>(data.Entity);
return default(T);
},
setter: (ref EntityInspectionData data, T value) => data.EntityManager.SetComponentData<T>(data.Entity, value)
);
}
private static IValueGetterSetter CreateSharedComponentDataGetterSetter<T>(ComponentType componentType) where T : struct, ISharedComponentData
{
return new GetterSetter<EntityInspectionData, T>(
getter: (ref EntityInspectionData data) =>
{
if (data.EntityManager.HasComponent(data.Entity, componentType))
return data.EntityManager.GetSharedComponentData<T>(data.Entity);
return default(T);
},
setter: (ref EntityInspectionData data, T value) =>
{
// There's currently some oddity with using SetSharedComponentData - it doesn't seem to update
// the values properly - and for the property bag values, the shared component data is completely funky.
//
// Our tentative "fix" for this is rather brutal, as you can see. This doesn't seem quite right.
// Please do clarify how this is meant to work.
using (var entities = data.EntityManager.GetAllEntities())
{
for (int i = 0; i < entities.Length; i++)
{
if (data.EntityManager.HasComponent(entities[i], componentType))
data.EntityManager.SetSharedComponentData(entities[i], value);
}
}
}
);
}
private static IValueGetterSetter CreateUnityObjectComponentGetterSetter<T>(ComponentType componentType) where T : Component
{
return new GetterSetter<EntityInspectionData, T>(
getter: (ref EntityInspectionData data) =>
{
if (data.EntityManager.HasComponent(data.Entity, componentType))
return data.EntityManager.GetComponentObject<T>(data.Entity);
return null;
},
setter: (ref EntityInspectionData data, T component) => { } // Cannot set this at all, as far as I can tell. That makes sense too.
);
}
private static IValueGetterSetter CreateBufferElementDataGetterSetter<T>(ComponentType componentType) where T : struct, IBufferElementData
{
ExpectedTypeMapping[typeof(T)] = typeof(BufferElementDataWrapper<T>);
return new GetterSetter<EntityInspectionData, BufferElementDataWrapper<T>>(
getter: (ref EntityInspectionData data) =>
{
return new BufferElementDataWrapper<T>()
{
Buffer = data.EntityManager.GetBuffer<T>(data.Entity)
};
//var buffer = data.EntityManager.GetBuffer<T>(data.Entity);
},
setter: (ref EntityInspectionData data, BufferElementDataWrapper<T> value) => { } // Makes no sense to set this
);
}
public bool ChildPropertyRequiresRefresh(int index, InspectorPropertyInfo info)
{
var data = this.ValueEntry.SmartValue;
using (var types = data.EntityManager.GetComponentTypes(data.Entity))
{
var expectedType = types[index].GetManagedType();
Type mapTo;
if (ExpectedTypeMapping.TryGetValue(expectedType, out mapTo))
{
expectedType = mapTo;
}
if (expectedType != info.TypeOfValue)
{
this.infos.Remove(index);
return true;
}
return false;
}
}
}
}
0)'PathEntityPropertyResolver.cs.metaData0*<08>fileFormatVersion: 2
guid: 5b7d3f44d799ea54b8d21c6054655d3c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0+'Path(EntitySelectionProxyPropertyProcessor.csData0,<08>//-----------------------------------------------------------------------
// <copyright file="EntitySelectionProxyPropertyProcessor.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System.Collections.Generic;
using Unity.Entities.Editor;
using Sirenix.OdinInspector.Editor;
public class EntitySelectionProxyPropertyProcessor : OdinPropertyProcessor<EntitySelectionProxy>
{
public override void ProcessMemberProperties(List<InspectorPropertyInfo> propertyInfos)
{
EntityInspectionData data = new EntityInspectionData()
{
EntityManager = (this.Property.ValueEntry.WeakSmartValue as EntitySelectionProxy).EntityManager
};
propertyInfos.AddValue(
name: "Entity",
getter: () =>
{
data.Entity = (this.Property.ValueEntry.WeakSmartValue as EntitySelectionProxy).Entity;
return data;
},
setter: (value) => data = value);
}
}
}
0-'Path-EntitySelectionProxyPropertyProcessor.cs.metaData0.<08>fileFormatVersion: 2
guid: 8d5567912231d0d4c9dd899d36fc2d37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0/'Path"EntitySharedComponentDataDrawer.csData00# //-----------------------------------------------------------------------
// <copyright file="EntitySharedComponentDataDrawer.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using Unity.Entities;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using Sirenix.Utilities.Editor;
public class EntitySharedComponentDataDrawer<T> : OdinValueDrawer<T> where T : struct, ISharedComponentData
{
//private static readonly string MessageBoxMessage = "Shared Components are acting weird - click to find out more.";
//private static readonly string MessageBoxDetailedMessage =
// "There's currently some oddities with using SetSharedComponentData - it doesn't seem to update " +
// "the values properly - and for the PropertyBag-backed values, the shared component data is completely funky " +
// "when editing it through the inspector." +
// "\n\n" +
// "We haven't tried to truly dig through the innards of the ECS system to fix this properly, as this is merely a demo. " +
// "For now, we just iterate through all entities and set shared component data everywhere whenever it is changed through " +
// "the inspector. This seems to sort of work fine, though it is pretty darn brutal.";
//private bool messageBoxIsFolded = true;
protected override void DrawPropertyLayout(GUIContent label)
{
var rect = OdinECSEditorGUI.HeaderLabel(typeof(T).FullName, OdinECSEditorGUI.EntityIcon, this.Property.Children.Count > 0);
GUI.Label(rect, "Shared Data", SirenixGUIStyles.RightAlignedGreyMiniLabel);
//this.messageBoxIsFolded = SirenixEditorGUI.DetailedMessageBox(
// MessageBoxMessage, MessageBoxDetailedMessage,
// MessageType.Warning, this.messageBoxIsFolded);
for (int i = 0; i < this.Property.Children.Count; i++)
{
this.Property.Children[i].Draw();
}
OdinECSEditorGUI.DrawVerticalInspectorSeparator();
}
}
}
01'Path'EntitySharedComponentDataDrawer.cs.metaData02<08>fileFormatVersion: 2
guid: e6df3c0dfd41ad947b0233147679aa1a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
03'PathOdinECSEditorGUI.csData04<08>//-----------------------------------------------------------------------
// <copyright file="OdinECSEditorGUI.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using UnityEditor;
using UnityEngine;
using Sirenix.Utilities.Editor;
using Sirenix.Utilities;
public static class OdinECSEditorGUI
{
private static Color darkerLinerColor = EditorGUIUtility.isProSkin ? new Color(0.11f, 0.11f, 0.11f, 0.294f) : new Color(0, 0, 0, 0.2f);
private static Color lighterLineColor = EditorGUIUtility.isProSkin ? new Color(1.000f, 1.000f, 1.000f, 0.103f) : new Color(1, 1, 1, 1);
private static Texture2D entityIcon;
public static Texture2D EntityIcon
{
get
{
if (entityIcon == null)
{
entityIcon = GUIHelper.GetAssetThumbnail(null, typeof(UnityEngine.Object), false);
}
return entityIcon;
}
}
public static void DrawHorizontalSeparator(Rect rect)
{
EditorGUI.DrawRect(rect, darkerLinerColor);
EditorGUI.DrawRect(rect.AlignTop(1), darkerLinerColor);
EditorGUI.DrawRect(rect.AlignBottom(1), lighterLineColor);
}
public static void DrawVerticalInspectorSeparator()
{
var rect = GUILayoutUtility.GetRect(0, 5 + 4);
rect.x -= 30;
rect.width += 60;
rect.y += 2;
rect.height -= 4;
OdinECSEditorGUI.DrawHorizontalSeparator(rect);
}
public static Rect HeaderLabel(string text, Texture2D icon, bool drawHeaderSeperator)
{
var rect = EditorGUILayout.GetControlRect(false);
GUI.Label(rect.AddXMin(10), text, SirenixGUIStyles.Label);
GUI.DrawTexture(rect.AddX(-6).AlignLeft(16).AlignCenterY(16), icon);
if (drawHeaderSeperator)
{
GUILayout.Space(4);
}
return rect;
}
}
}
05'PathOdinECSEditorGUI.cs.metaData06<08>fileFormatVersion: 2
guid: 0efba3d37f8e5424184719fd367cbfe6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
07'Path!OdinEntitySelectionProxyEditor.csData08U//-----------------------------------------------------------------------
// <copyright file="OdinEntitySelectionProxyEditor.cs" company="Sirenix ApS">
// Copyright (c) Sirenix ApS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Sirenix.OdinInspector.Modules.Entities
{
using System;
using System.Linq;
using UnityEditor;
using Unity.Entities;
using Unity.Entities.Editor;
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using Sirenix.Serialization;
using System.Reflection;
using Sirenix.Utilities.Editor;
[CustomEditor(typeof(EntitySelectionProxy))]
[InitializeOnLoad]
public class OdinEntitySelectionProxyEditor : Editor
{
static OdinEntitySelectionProxyEditor()
{
if (SystemInclusionList_Type != null)
{
SystemInclusionList_OnGUI_Method = SystemInclusionList_Type.GetMethod("OnGUI", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(World), typeof(Entity) }, null);
}
EditorApplication.update += ForceOdinEditor;
ForceOdinEditor();
}
private static void ForceOdinEditor()
{
// We have to be a little forceful with this
CustomEditorUtility.SetCustomEditor(typeof(EntitySelectionProxy), typeof(OdinEntitySelectionProxyEditor), false, true);
ScriptableObject proxy = null;
Editor editor = null;
try
{
proxy = CreateInstance(typeof(EntitySelectionProxy));
editor = Editor.CreateEditor(proxy);
if (editor != null && editor is OdinEntitySelectionProxyEditor)
{
// Done! Unity got the message.
EditorApplication.update -= ForceOdinEditor;
//Debug.LogError("Sucess!");
}
else
{
//Debug.LogError("Trying again!");
}
}
finally
{
if (proxy != null)
DestroyImmediate(proxy);
if (editor != null)
DestroyImmediate(editor);
}
}
private static readonly Type SystemInclusionList_Type = TwoWaySerializationBinder.Default.BindToType("Unity.Entities.Editor.SystemInclusionList");
private static readonly MethodInfo SystemInclusionList_OnGUI_Method;
private object systemInclusionList;
private PropertyTree tree;
private void OnEnable()
{
if (SystemInclusionList_Type != null && SystemInclusionList_OnGUI_Method != null)
{
systemInclusionList = Activator.CreateInstance(SystemInclusionList_Type);
}
}
public override void OnInspectorGUI()
{
// Ugh, reference mismatch between UnityEngine.CoreModule.dll and UnityEngine.dll in our module dev environment
// means we need this extra cast. Whatever! :D
var proxy = (EntitySelectionProxy)(object)this.target;
if (this.tree == null)
{
this.tree = PropertyTree.Create(this.serializedObject);
}
GUI.enabled = true;
this.tree.BeginDraw(true);
string name = proxy.EntityManager.GetName(proxy.Entity);
if (string.IsNullOrEmpty(name))
{
name = "Entity " + proxy.Entity.Index;
}
GUILayout.Space(5);
EditorGUILayout.LabelField(name, SirenixGUIStyles.BoldTitle);
EditorGUILayout.LabelField("World: " + proxy.World.Name + ", Index: " + proxy.Entity.Index + ", Version: " + proxy.Entity.Version, SirenixGUIStyles.Subtitle);
OdinECSEditorGUI.DrawVerticalInspectorSeparator();
var entityProp = this.tree.RootProperty.Children["Entity"];
for (int i = 0; i < entityProp.Children.Count; i++)
{
entityProp.Children[i].Draw();
}
this.tree.EndDraw();
GUILayout.FlexibleSpace();
if (this.systemInclusionList != null)
{
SystemInclusionList_OnGUI_Method.Invoke(this.systemInclusionList, new object[] { proxy.World, proxy.Entity });
}
else
{
SirenixEditorGUI.ErrorMessageBox("Could not find internal Unity type and method 'SystemInclusionList.OnGUI(World world, Entity entity)'. System rendering is switched off.");
}
if (EditorApplication.isPlaying)
{
this.Repaint();
}
}
}
}
09'Path&OdinEntitySelectionProxyEditor.cs.metaData0:<08>fileFormatVersion: 2
guid: 79f35c4050aa1504aa5381f29c5f3c02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0;'Path-Sirenix.OdinInspector.Modules.Entities.asmdefData0<<08>{
"name": "Sirenix.OdinInspector.Modules.Entities",
"references": [ "Unity.Entities", "Unity.Entities.Editor", "Unity.Mathematics.Extensions", "Sirenix.OdinInspector.Attributes", "Sirenix.OdinInspector.Editor", "Sirenix.Utilities", "Sirenix.Utilities.Editor" ],
"includePlatforms": [ "Editor" ],
"excludePlatforms": [],
"allowUnsafeCode": true,
"autoReferenced": true,
"overrideReferences": false,
"precompiledReferences": [ "Sirenix.Utilities.dll", "Sirenix.Utilities.Editor.dll", "Sirenix.OdinInspector.Attributes.dll", "Sirenix.OdinInspector.Editor.dll", "Sirenix.Serialization.dll" ],
"defineConstraints": []
}0='Path2Sirenix.OdinInspector.Modules.Entities.asmdef.metaData0><08>fileFormatVersion: 2
guid: c65d1f394d35e5940ae9f48d88159161
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: