-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to make it work in Unity 2019? #8
Comments
Hello there. I think the error you're saying happens because the original it uses a NativeArray to do some render stuff, like this: // RendererMesh.cs or RendererProcedual.cs
// ... line160
// TODO: Convert NativeArray to C# array or list (remove collections).
NativeArray<ImDrawVert> vtxArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<ImDrawVert>(
(void*)drawList.VtxBuffer.Data, drawList.VtxBuffer.Size, Allocator.None);
NativeArray<ushort> idxArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<ushort>(
(void*)drawList.IdxBuffer.Data, drawList.IdxBuffer.Size, Allocator.None); There is no workaround yet but If you rewrite those lines I'll be glad to merge with the main. =) Thanks. |
okay, I've cloned your project directly into the Assets [this way it didn't pull the dependencies] of an empty Unity 2019 Project and it didn't complain about collections, rather it complained about the SetSubMeshes, as it didn't exist, so I had to set the meshes one by one in the loop above: // [RenderMesh.cs]
for (int i = 0, iMax = drawList.CmdBuffer.Size; i < iMax; ++i)
{
ImDrawCmdPtr cmd = drawList.CmdBuffer[i];
SubMeshDescriptor descriptor = new SubMeshDescriptor
{
topology = MeshTopology.Triangles,
indexStart = idxOf + (int)cmd.IdxOffset,
indexCount = (int)cmd.ElemCount,
baseVertex = vtxOf + (int)cmd.VtxOffset,
};
descriptors.Add(descriptor);
// This line HERE *********
_mesh.SetSubMesh(i, descriptor, NoMeshChecks);
}
vtxOf += vtxArray.Length;
idxOf += idxArray.Length;
}
}
_mesh.UploadMeshData(false); Now, I am not sure, but it appears that collections used are there by default in Unity 2019, maybe they separated it into a package later to make Unity lighter, so I am thinking maybe we could just modify this part of the code, and add a conditional package dependency based on Unity version, not sure if that's possible? |
Alright, I got it working without the NativeArrays.. I do not think it's the best way as it possibly affects performance but I can't tell how much.. plus I don't think there's another way. [NOTE] Not sure if it's something local, but I first went and just removed the Collections package and it worked in 2019 after modifying what I wrote in a comment above, then I run the same project and upgraded it to 2020 and it was still working without the package. Are you sure you need that dependency? Here's a screenshot of everything working with FPS, I'll do a pull request and then decide whether or not you want to use it, meanwhile I'll for the repo because I need this asap. |
Wow, nice! I'll test this into a different branch. [edit] Thank you for your effort. |
So to sum up... I did some more testing, there are some more issues, for example while the code I wrote there fixes the compile error and it seems to be working, some parts of imgui features do not work as expected.. not sure if I can further investigate, however this concerns only the Mesh rendering type, you can go fine with Procedural. About the NativeArray issues, I believe you can freely get rid of the dependency, test it out with your version of Unity to be sure, but here it works fine without it, because it's a built-in feature of Unity. And that's pretty much it, in the end we just gotta fix that compile error and get rid of the dependency. |
The original goal doesn't include the 2019 support, so I think the best way is to rip off render mesh for < 2020. Thanks again! |
Sure, that will be quite enough! :) and np, doing this because I also need it hehe, might hear from me again :) |
Hey, I am having trouble using this in Unity 2019, there is an error in the Unity Collections dependency package, something about ReadOnly missing from the NativeArray.
The text was updated successfully, but these errors were encountered: