scellecs / morpeh Goto Github PK
View Code? Open in Web Editor NEW🎲 ECS Framework for Unity Game Engine and .Net Platform
License: MIT License
🎲 ECS Framework for Unity Game Engine and .Net Platform
License: MIT License
Unity 2021.1.14 Unity.Collections.LowLevel.Unsafe.UnsafeUtility.SizeOf() возвращает неверный результат для компонента с одним булевым полем из-за чего тип помечается как маркер. System.Runtime.InteropServices.Marshal.SizeOf(default(T)) отрабатывает как надо.
When writing the editor extension for the inspector Installer
script, I had a problem in that I could not initialize BasePair
normally from the script, because the BasePair.System
field does not have a public setter.
It's too hard to use WorldViewer without search.
I added this feature to may project ([Searchable] parameter of private List Entities at WorldViewer) and it works fine.
Maybe it's good idea to add this feature to master.
Если разделить проект на отдельные пакеты, то появится возможность использовать в проекте только нужные части морпеха (например, отказаться от использования утилит и заменить глобалы собственной реализацией)
В https://github.com/scellecs/morpeh/blob/2022-major/Unity/Providers/EntityProvider.cs#L36 используется синтаксис C#8 который не поддерживается в Unity 2020.1
Currently, ENABLE_BURST_AOT define is set in non-burst Unity projects (for some strange reason). We need a better solution to detect Burst installations with defines.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int NumberOfTrailingZeros(int i) {
switch (((uint)(i & -i) * 0x077CB531u) >> 27) {
case 0: return 0;
case 1: return 1;
case 2: return 28;
case 3: return 2;
case 4: return 29;
case 5: return 14;
case 6: return 24;
case 7: return 3;
case 8: return 30;
case 9: return 22;
case 10: return 20;
case 11: return 15;
case 12: return 25;
case 13: return 17;
case 14: return 4;
case 15: return 8;
case 16: return 31;
case 17: return 27;
case 18: return 13;
case 19: return 23;
case 20: return 21;
case 21: return 19;
case 22: return 16;
case 23: return 7;
case 24: return 26;
case 25: return 12;
case 26: return 18;
case 27: return 6;
case 28: return 11;
case 29: return 5;
case 30: return 10;
case 31: return 9;
}
return 0;
}
I've got error
ExecutionEngineException: Attempting to call method 'Morpeh.ComponentsCacheDisposable`1[[Tanks.GameInput.GameUser, Tanks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::.ctor' for which no ahead of time (AOT) code was generated.
while trying to build morpeh.examples.tanks for Windows with IL2CPP using Unity 2019.4.40f1.
But everything works fine, when I change ComponentsCacheDisposable visibility to public and call constructor directly from system's OnAwake()
.
Based on conecept like https://github.com/stella3d/SharedArray
I think deleting this attribute will provide access to variables of components in editor, rather than changing them in script.
Если кодом в рантайме удалить компонент, у которого есть провайдер, и при этом будет открыт инспектор этого объекта, тогда падает эта ошибка
Пример:
Exception: [MORPEH] You're trying to get on entity 212 a component that doesn't exists!
Morpeh.ComponentsCache`1[T].GetComponent (Morpeh.Entity entity) (at Library/PackageCache/com.scellecs.morpeh@22b6b7c1ca/Core/ComponentsCache.cs:148)
Morpeh.MonoProvider`1[T].get_Data () (at Library/PackageCache/com.scellecs.morpeh@22b6b7c1ca/Unity/Providers/MonoProvider.cs:24)
(wrapper dynamic-method) System.Object.Morpeh.MonoProvider`1[[HealthBarRenderComponent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].get_Data(Morpeh.MonoProvider`1<HealthBarRenderComponent>&)
Sirenix.OdinInspector.Editor.GetterSetter`2[TOwner,TValue].GetValue (TOwner& owner) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/GetterSetter.cs:270)
Sirenix.OdinInspector.Editor.AliasGetterSetter`4[TOwner,TValue,TPropertyOwner,TPropertyValue].GetValue (TOwner& owner) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Infos/AliasGetterSetter.cs:70)
Sirenix.OdinInspector.Editor.PropertyValueEntry`2[TParent,TValue].UpdateValues () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:1049)
Sirenix.OdinInspector.Editor.PropertyValueEntry.Update () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:226)
Sirenix.OdinInspector.Editor.InspectorProperty.UpdateValueEntry () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:1436)
Sirenix.OdinInspector.Editor.InspectorProperty.Update (System.Boolean forceUpdate) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:1090)
Sirenix.OdinInspector.Editor.InspectorProperty.OnStateUpdate (System.Int32 treeID) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:663)
Sirenix.OdinInspector.Editor.InspectorProperty.OnStateUpdate (System.Int32 treeID) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:668)
Sirenix.OdinInspector.Editor.PropertyTree.BeginDraw (System.Boolean withUndo) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:450)
Sirenix.OdinInspector.Editor.PropertyTree.Draw (System.Boolean applyUndo) (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:388)
Sirenix.OdinInspector.Editor.OdinEditor.DrawTree () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:93)
Sirenix.OdinInspector.Editor.OdinEditor.DrawOdinInspector () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:216)
Sirenix.OdinInspector.Editor.OdinEditor.OnInspectorGUI () (at X:/Repositories/sirenix-development/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:85)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <2758fd44916644e3a3b65c9d4809b7f9>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
На данный момент морпех переиспользует ID поэтому их нельзя хранить отдельно от Entity (например, для передачи в Job и обработки в следующем кадре).
[Test]
public void EntityIdUniqueness()
{
var world = World.Create();
var entity1 = world.CreateEntity();
var entityId1 = entity1.ID;
entity1.Dispose();
world.Update(0.01f);
var entity2 = world.CreateEntity();
var entityId2 = entity2.ID;
Assert.AreEqual(entityId1, entityId2);
}
Добавить уникальное поле entity.EntityID
, где EntityID это
public struct EntityID {
public int ID; // индекс
public int Gen; // уникальное число
public bool Equal(EntityID other);
public static bool operator ==(EntityID a, EntityID b);
public static bool operator !=(EntityID a, EntityID b);
public static EntityID Invalid => new EntityID {ID = -1, Gen = -1};
}
и метод-расширение
// возвращает true только если
// entityID != EntiyID.Invalid && world.entities[entityId.ID].IsAlive() && world.entities[entityId.ID].Gen == entityId.Gen
public static bool TryGetEntity(this World world, EntityID entityID, out Entity entity);
public class DamageEvent : CustomGlobalEvent<DamageEvent.Args> {
public struct Args { public EntityID targetID; }
}
public class AttackSystem : UpdateSystem {
public DamageEvent damageEvent;
public override void OnUpdate(float deltaTime) {
Entity target = ...;
damageEvent.NextFrame(new DamageEvent.Args { targetID = target.EntityId });
}
}
public class DamageSystem : UpdateSystem {
public DamageEvent damageEvent;
public override void OnUpdate(float deltaTime) {
if (!damageEvent.IsPublished) {
continue;
}
foreach (var evt in damageEvent.BatchedChanges) {
if (!this.World.TryGetEntity(evt.targetID, out var targetEntity)) {
continue;
}
// use targetEntity
}
}
}
introduce new system type?
Hi there, I noticed a very small issue when reading the GitHub page for this library. Even though the license reads as an MIT license for some reason GitHub is not picking that up and indicating you should read the contents for more details.
Though its a very small thing, when other people read this page or view it in their search results this project would not show as having an MIT license. I've had this problem before and the way I've usually resolved it is to delete the existing license and re-add it through the GitHub website. Its usually some very slight, inane formatting or naming issue that causes it to not show correctly..
I hope this is helpful for you!
IOS build crashes at startup with this message:
ExecutionEngineException: Attempting to call method 'Morpeh.TypeIdentifier`1[[MyTestComponent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::Warmup' for which no ahead of time (AOT) code was generated.
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at Morpeh.WorldExtensions.InitializationDefaultWorld () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.UnhandledExceptionHandler:PrintException(String, Exception)
UnityEngine.UnhandledExceptionHandler:HandleUnhandledException(Object, UnhandledExceptionEventArgs)
System.UnhandledExceptionEventHandler:Invoke(Object, UnhandledExceptionEventArgs)
I fixed this wrapping these 'warm types' codes in InitializationDefaultWorld method with !UNITY_IOS define. Not sure if this problem exists on other AOT platforms too
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.