wangguan
2020-12-29 452c75675679c44cc39b04bdb7d330d7c5c14d5c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
/MSirenix.OdinInspector.Editor.Modules.ModuleData, Sirenix.OdinInspector.Editor'IDUnity.EntitiesVersion/System.Version, mscorlibFiles/‡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Ä//-----------------------------------------------------------------------
// <copyright file="AABBAttributeProcessor.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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þfileFormatVersion: 2
guid: 99aec795f53d8e143a1d7f42bcc5b17b
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0'PathBufferElementDataWrapper.csData0¶//-----------------------------------------------------------------------
// <copyright file="BufferElementDataWrapper.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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
þ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 IVS">
// Copyright (c) Sirenix IVS. 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þfileFormatVersion: 2
guid: 670d7bc249ee5584c90508555cbe66e7
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0'Path"DynamicBufferCollectionResolver.csData0Ù//-----------------------------------------------------------------------
// <copyright file="DynamicBufferCollectionResolver.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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;
 
    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);
        }
 
        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þfileFormatVersion: 2
guid: 4112ab7873dc6c04495d3ed9aa3b0cc6
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0'PathEntityAttributeProcessor.csData0Ç//-----------------------------------------------------------------------
// <copyright file="EntityAttributeProcessor.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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þfileFormatVersion: 2
guid: 583a30f7f1c035640ab8da4ea54837ab
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0'PathEntityComponentDataDrawer.csData0â//-----------------------------------------------------------------------
// <copyright file="EntityComponentDataDrawer.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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þ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 IVS">
// Copyright (c) Sirenix IVS. 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þfileFormatVersion: 2
guid: f7edf656bab5bc641a0a4677dbcbc4e2
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0'Path"EntityManagedComponentAttribute.csData0 õ//-----------------------------------------------------------------------
// <copyright file="EntityManagedComponentAttribute.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
 
namespace Sirenix.OdinInspector.Modules.Entities
{
    using System;
 
    [AttributeUsage(AttributeTargets.All)]
    public class EntityManagedComponentAttribute : Attribute
    {
    }
}
0!'Path'EntityManagedComponentAttribute.cs.metaData0"þfileFormatVersion: 2
guid: 92700f432a2fa8c4f94cb50b35e12818
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0#'Path(EntityManagedComponentAttributeDrawer.csData0$ä//-----------------------------------------------------------------------
// <copyright file="EntityManagedComponentAttributeDrawer.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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&þ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 IVS">
// Copyright (c) Sirenix IVS. 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;
 
    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 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*þfileFormatVersion: 2
guid: 5b7d3f44d799ea54b8d21c6054655d3c
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0+'Path(EntitySelectionProxyPropertyProcessor.csData0,ñ//-----------------------------------------------------------------------
// <copyright file="EntitySelectionProxyPropertyProcessor.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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.þ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 IVS">
// Copyright (c) Sirenix IVS. 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þfileFormatVersion: 2
guid: e6df3c0dfd41ad947b0233147679aa1a
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
03'PathOdinECSEditorGUI.csData04Ý//-----------------------------------------------------------------------
// <copyright file="OdinECSEditorGUI.cs" company="Sirenix IVS">
// Copyright (c) Sirenix IVS. 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þ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 IVS">
// Copyright (c) Sirenix IVS. 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:þfileFormatVersion: 2
guid: 79f35c4050aa1504aa5381f29c5f3c02
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 
0;'Path-Sirenix.OdinInspector.Modules.Entities.asmdefData0<”{
    "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>­fileFormatVersion: 2
guid: c65d1f394d35e5940ae9f48d88159161
AssemblyDefinitionImporter:
  externalObjects: {}
  userData: 
  assetBundleName: 
  assetBundleVariant: