#archived-code-advanced

1 messages · Page 131 of 1

exotic trout
#

Something like this probably requires solid experience in memory allocation and the ins and outs of the addressable system, plus seemingly a lot more time to review the codebase than you seem to have been provided and/or have remaining

hybrid tundra
#

yeah

#

this is why I'm afraid

stuck plinth
#

there's some simple and dirty strategies you could try if you don't have time to manage things properly, like if you know all these assets are being loaded for the duration of a level, make a static list of handles somewhere, throw the handle from every LoadAssetAsync call in there, and clear and release everything when you switch levels

hybrid tundra
echo coral
#

(you can release via the handle or the asset itself)

hybrid tundra
#

but this is a good idea

hybrid tundra
#

or rather answer me one thing?

#

if its related to assetbundles, then shouldn't be this solution worked temporarily?

#

because its allegedly clears up every addressable assetbundles

#

forcely

#

so then I shouldn't see any assetbundle reference in Memory Profiler after calling this, right?

echo coral
#

this is a hack and will surely fuck other things

stuck plinth
#

if it works as that person says i guess it should probably unload everything? i'm not going to try it myself though lol

hybrid tundra
#

because its just a quick test

echo coral
#

hey you do you

hybrid tundra
#

I have very limited time

#

correct Releasing can take weeks

#

which I don't have now

#

but I would invest time, if I would see it would work

#

because currently I'm not really sure it would

#

so... I wanted to use this to test IF the issue is with the addressables really

hybrid tundra
#

would you be able to do it in 1 month?

exotic trout
echo coral
#

Yea i dont know your project but as an outsider all i can do is suggest solutions and methods you should use with addressables and hope you can apply them where it matters most to make some impact.

hybrid tundra
#

I mean there most be a way to not sleep and live 0-24 in the office for the next 2-3 weeks

exotic trout
#

Objectively either the deadline changes, requirement changes or person doing the work changes

hybrid tundra
#

objectively the last one seems horrible

#

so can you check the code in here?

#

I did a quick test with it

#

shouldn't it clear up all possible assetbundle references?

#

just to know if its worth the time to make a manager and place handles there to release all of them when needed

exotic trout
# hybrid tundra objectively the last one seems horrible

Apologies if that came off rude, I say that just to mean there’s only so many answers (if any) that can fit in that venn digram of parameters. This server can help navigate those options but it won’t increase how many are actually available

untold moth
#

If you look closely at your screenshot, you'll see that this is a different reference hierarchy to what you shared before, so your changes probably did have an effect.
If you investigate closer to the root of the cause it might be a lot easier to solve the issue, rather than modifying hundreds of other scripts that could be in the middle of the reference chain.

untold moth
# hybrid tundra do I look like I don't listen for suggestions?

But you don't. You keep on ignoring the correct way of investigating and fixing this issue. How many times were you told to look at the root cause and read the profiler info? But you kept on trying to cut the references in the middle of the reference chain. The only time you did it right was a few days ago when you successfully get rid of some manager object at the root of the reference chain - you found the root cause, confirmed the profiler info that mentions the cause and eliminated it. But after that you gave up and started doing it the wrong way.

hybrid tundra
hybrid tundra
#

but if you would explain me, then I would understand it

hybrid tundra
#

how do you track back its root cause?

#

its not really trivial

#

for example I can't find PickableMonobehavior[] anywhere in the project

#

I don't know where are those HashSet.Slot<...> things

#

this is a different one

#

it says its in an assetbundle

#

I have opened Asset Management - Addressables - Groups, typed this Tex_fx_Shoot&Hit_set name into the search bar, none of the addressable bundles contain a texture like this

#

I have selected this exact texture in the Project window, even the "Addressables" is disabled in the Inspector view for this

#

so it would be a great help if I could understand anything of the References Hierarchy

#

because currently I don't understand it

exotic trout
#

there's lots of resources online for learning addressables

steel snow
#

what is a performant way to update indices in a mesh? theres no way to just pass in updates as a slice it requires you to get the entire index buffer update it then pass it back in which is not ideal

flint sage
#

Shaders 😛

steel snow
#

i need lighting and navmesh to update with it though

#

i tried:

            using (var input = Mesh.AcquireReadOnlyMeshData(mesh))
            {
                using (var output = Mesh.AllocateWritableMeshData(mesh))
                {
                    var indices = input[0].GetIndexData<int>();
                    var buffer = output[0].GetIndexData<int>();
                    buffer[start] = a;
                    buffer[start + 1] = b;
                    buffer[start + 2] = c;
                    indices.CopyTo(buffer);
                    Mesh.ApplyAndDisposeWritableMeshData(output, mesh);
                }
            }

but that didn't work

untold moth
# hybrid tundra

Start by selecting the net object controller and reading it's info.
As well as thinking whether it's supposed to be loaded at that point of time or not? If yes, then pick the next thing in the hierarchy - FXCollection. Is it supposed to be loaded? If not, then read the info. Understand why it is still loaded.

#

We've went over this many many times by now.

hybrid tundra
#

I just want to avoid this, because this seems extreme amount of time

#

by the way

#

FXCollection is not the root

untold moth
#

Avoid how? By trying random changes? You're just gonna spend more time on that and not get closer to solution. Understanding the issue is the key.

hybrid tundra
#

and you wrote to investigate the root

#

I would deal with FXCollection, but its not the root at all

untold moth
# hybrid tundra and you wrote to investigate the root

The root would be the last object that is not supposed to be loaded. I don't know about the ones you shared in the screenshot. You'll need to look at them. It could very much be that they are supposed to be loaded.

#

And if not, you'll need to read their info and understand why they are still loaded.

hybrid tundra
#

@untold moth now from 1369 textures, I could reach 1044 loaded textures

hybrid tundra
#

okay, so, can we go through this like if I would be a complete idiot?

#

first thing I don't understand

#

NetObjectController is not needed in the main menu, so I want to get rid of it

#

it says "referenced by 10"

#

I can only see 8 in here, so I'm already confused

#

where are these HashSet.Slot and other things?

untold moth
untold moth
dusty wigeon
#

Just need to set something to null, the object is already destroyed.

#

Which is potentially all of the things you are showing.

untold moth
#

It's likely that most of these 10 references are cyclic and possibly would go away themselves if you eliminate the root of the issue. There can't be that many references to objects in another scene - only DDOL or static fields could be culprits.

hybrid tundra
untold moth
#

Then investigate until you find the cause. There might be other scenarios.

hybrid tundra
#

it says "PlayerManager has a static reference on type PlayerManager

#

but I can't see that anywhere in that class

#

maybe I'm blind or I would need a glass

#

no idea

untold moth
#

Is that PlayerManager supposed to be loaded at that point?

hybrid tundra
#

but I already removed MultiplayerGame days ago

untold moth
#

The fact that there's a delegate in between, probably sugests that the PlayerManager is subscribed to an event in the MultiplayGame.

#

Or the other way around.

#

OnUsablePlayerArrayChangedDelegate

#

sounds like a typical case of forgetting to unsubscribe from events.

hybrid tundra
untold moth
#

Yes. In the end it's holding a reference to the object.

hybrid tundra
#

fantastic

untold moth
#

Is the PlayerManager even supposed to be alive in the menu scene?

untold moth
#

That sounds like a bad decision to me. What exactly do you need it there for?

hybrid tundra
#

I only know 2% of code base

untold moth
#

Anyways, try unsubscribing from whatever it's subscribed to on scene change.

hybrid tundra
#

and Game.cs is parent of MultiplayerGame

#

and the unsubscribe happens in OnDestroy (which seems valid, since MultiplayerGame gets destroyed)

untold moth
#

What? Who unsubscribes where? The PlayerManager needs to unsubscribe. Not the other way around. If I get it right.

hybrid tundra
untold moth
#

Also that it doesn't subscribe more than once.

hybrid tundra
#

and -= in ondestroy

#

so only subscribes once

hybrid tundra
stuck plinth
#

it might be worth verifying that in the debugger, if you inspect the value you should be able to see the subscribed delegate list

hybrid tundra
#

but the gameobject disappears in Hierarchy

#

so I guess the same thing happens again

#

only partially running the OnDestroy

untold moth
#

Do you see any errors in the console/log?

hybrid tundra
#

a week ago or something, I tried to do releasing addressables the "right way"

untold moth
#

Well, errors should be the first thing you ever look at

#

And fix

hybrid tundra
untold moth
#

Before doing anything else

hybrid tundra
#

there are a lot of them

untold moth
hybrid tundra
#

I didn't have time to start with solving errors

untold moth
#

But then you gonna spend more time investigating issues that these errors are causing😅
Like memory leaks

#

Not to mention that a game with errors is not ready for release.

ebon abyss
#

Depends. I've got a few I can live with 😉

#

(I have a few debug shader passes that don't compile and cba to fix)

untold moth
#

At the very least you should be fully aware of where they come from and what effects they have on your program

#

If the error is in the middle of a method and are not caught in any way, this means that they break some logic. This is like a no-no. If these are just error level logs without breaking the execution flow, it might be fine. Depends.

ebon abyss
#

Like runtime exceptions? Yeah that's dangerous

#

They also break the entire call stack, so depending on how deep it is, it might break the whole game state.

hybrid tundra
#

I mean I have like tons of Debug.LogErrors

#

for things which could have been just logged normally

#

(I wasn't the dev of these logerrors)

#

because there are a lot of these, I got used to not looking at these

untold moth
#

Are you testing with a debugger connected? It should break on real errors.

ebon abyss
#

This sounds like something to go through for like 20 minutes and fix them

#

Because "error that's just a normal log" is... pretty undesirable

stuck plinth
#

especially if you're seeing problems like OnDestroy methods not completing because of errors!

#

that's a pretty bad one

ebon abyss
#

If that's the case then it's an exception, not an error log 😉

stuck plinth
#

an exception is a type of error 😛

echo coral
#

Exceptions affect logic, logged text does not

#

well not directly anyway 🤔

stuck plinth
#

the context here is that they may be missing an error logged by an exception being thrown because there's so many other errors being logged, exceptions in the unity console appear like any other error

scenic forge
#

This has quite the On Error Resume Next energy.

echo coral
#

Yea im sure there are some that need to be examined but if most are caught and logged things may appear to be working

hybrid tundra
#

@stuck plinth @untold moth @ebon abyss no, the OnDestroy was half-complete because of a real error I made 1 week ago, when I tried to collect AsyncOperationHandles by classes which makes Addressables.LoadAssetAsync calls. I just did it wrongly.
About 5 hours ago I made a separate class which collects AsyncOperationHandles from all classes whichcalls Addressables.LoadAssetAsync, and when I switch back to the main menu scene, I just unloads all which was part of the gameplay scene. This part works, this was freeing up like 100-200 mb of memory. But from my old solution when I tried to do things the right way (that "1 week ago" solution I mentioned) that broke things up.
And I just didn't see these relevant errors to this, because I have Debug.LogErrors for a lot of things to be able to print messages in NDA platforms visually.

#

so not the Debug.LogErrors made the OnDestroy stop working

#

I don't understand this, seriously

#

PhotonView has 3 static fields, I have cleaned up all 3

#

it doesn't have a static List<> field

hybrid tundra
#

okay, I could eliminate it from a fully different field I expected

hybrid tundra
#

okay, so I still need to read the same thing like 4-5 times to be able to actually find the reference

#

but maybe I can start to be able to use this "Referenced by" window

#

it was not really trivial

hybrid tundra
#

@untold moth are you here?

untold moth
hybrid tundra
#

what could reside in the ALLOC_DEFAULT_MAN: TLSF Memory Block 44?

#

ALLOC_CACHEOBJECTS is also huge

#

but the Top Unity Objects Categories doesn't tell me that the issues would still be with those things

#

am I being ignored?

#

@untold moth

stuck plinth
#

c'mon, don't spam ping individual people for replies

#

this is a volunteer help channel, nobody owes anyone anything here, it's also the middle of the working day lol

untold moth
hybrid tundra
#

I have eliminated the texture leaking though

#

it seems

#

I will check the stability of the game though

untold moth
# hybrid tundra

This is all "reserved". It's likely memory that unity allocated and released before and it holds on to it to so that it can reuse it.

hybrid tundra
#

because I'm still annoyed by that 1 gb of "something" lurking in the memory

untold moth
#

Requesting memory from the system is expensive, so engines usually allocate ahead of time or hold on to memory that was released in their allocators so that it can be reused later on.

echo coral
#

Unity specifically mention how once the managed heap expands they rarely free some of it. It will often have lots of un used space

hybrid tundra
#

thanks

#

since then I tested the build on NDA

#

much more stable!

#

and now I get out of memory error, but in different way, its complaining about rendertextures now

#

so I can progress at least

#

now I have no idea how to free up a RenderTexture, if its not used anywhere in code, and if its only referenced by UnityEngine.Rendering.RTHandle

untold moth
echo coral
#

Do you know if the project uses render textures anywhere?

hybrid tundra
hybrid tundra
echo coral
untold moth
hybrid tundra
echo coral
#

could be a package or the render pipeline

untold moth
echo coral
#

^ yea, i forget if things like the depth texture and normal texture (if enabled) are used as render textures or not

hybrid tundra
#

never mind, I have found RTHandles in the project

echo coral
#

as these can be enabled to be made in urp for example on forward rendering

hybrid tundra
#

its just the solution grouped into many different projects

#

so I couldn't find them before

echo coral
#

sounds shit

#

i do not envy you 😆

untold moth
#

Sounds like separate assemblies, which isn't that uncommon.

echo coral
#

that should be easily searchable with their ide

untold moth
#

Yep

hybrid tundra
#

any idea how to eliminate this?

untold moth
# hybrid tundra

Most of it sounds like engine internal renter targets. The first one seems to be a render target for a custom pass, so it could be created by some kind of renderer feature or something.

#

I don't think you can remove any aside from the first one(which might break some custom rendering feature in the project).

hybrid tundra
#

wait a min

untold moth
#

But maybe select one and have a look at it's info

hybrid tundra
#

since then I realized

#

I could free up memory only in the first level

#

the other levels are still leaking textures as well

#

today I tested a different level, and based on the error message, I thought I had a different issue

#

but apparently the issue is probably the same as before

#

only the message was different

untold moth
#

I'd use a native memory analyzing tool and reproduce an OOM crash. Then look at the captured data.

hybrid tundra
#

GPU and D3D stops sending values

#

Memory usage is around max

#

CPU 1 is at 100% constantly

#

this happens when out of memory error happens

untold moth
#

You need to use the dedicated memory tools for the platform. On windows and Xbox it's PIX. PlayStation has memory analyzer.
Read your platform documentation. They usually explain in details how to use these tools.

hybrid tundra
untold moth
#

Use the mentioned tools to understand the cause of the issue before optimizing anything.

hybrid tundra
untold moth
#

Well, you didn't really lead the conversation in this direction.

#

I mean, unity profiler might be useful to a degree I guess. But you need a capture closer towards the crash. I'm not sure unity can do a trace like capture like the native profiling tools.

ebon abyss
untold moth
#

Read the documentation: determine the platform memory limitations. Then look at the tools data to confirm if it's actually an OOM and not some other issue.
Then use these tools to investigate further.

ebon abyss
#

It's what I did for what I'm assuming is the same device.

hybrid tundra
#

ok thanks

#

I will check it

untold moth
#

Consoles usually use UMA, so reducing VRAM consumption might help even if it's not the main culprit.

hybrid tundra
#

this is why I called it texture memory leak

#

it helped though, didn't crash for a lot of time, but eventually it crashed for the same reason

untold moth
#

Is it crashing in the main menu?

hybrid tundra
#

during loading

#

but even the main menu is full of huge textures

#

which I can't really decrease further

ebon abyss
#

Are you loading scenes additively without clearing unused assets?

untold moth
#

If using lower mip levels still causes a crash eventually, then it's definitely a memory leak. You need to investigate it using the native tools as I mentioned earlier.

echo coral
#

its not what you want to hear but if asset loading and unloading was improved correctly from the start it would be easier to solve and manage.
If memory runs out when loading required assets then you know you need to scale back certain things (e.g textures used, max size, quality ect...)

I don't know if you went with the "nuke all addressables" solution but it wont provide reliable results

untold moth
#

I think they jumped on the project in the middle and were not involved in most of it's developement.

hybrid tundra
#

I would definitely do that

#

but there won't be time for that

echo coral
#

It sucks but i stand by what i said

#

other people made poor decisions and you have to do what you can to optimise it

untold moth
#

There aren't that many ways to have a memory leak in Unity. Use the dedicated tools and you'll figure it out.

#

Perhaps should've mentioned that you have a leak earlier. Removing references in the main menu scene probably didn't really help with anything.

#

As soon as a scene where these references are reassigned, is loaded, the dangling objects would be released anyway.

hybrid tundra
#

anyway, I believe I have fixed the leak only on one level

#

I'm not sure

#

but maybe (based on Unity Profiler, the texture memory decreased a lot)

#

during the weekend I will read about the native profiling tools

#

but for now, I only know that for the other levels I still can see addressable bundles in the references

#

those are textures which otherwise not in any addressable bundles, so I guess they get loaded because of some dependency

#

how can I figure out which addressable bundles loads certain textures? because Addressable Groups window is unusable for me

#

(why? because memory profiler says its named as e62badcblablablabla, and in Addressables Groups there's no group named like that)

stuck plinth
#

bundles and groups are two different things, you can turn on the build layout report in the addressables settings

#

the filenames and contents of each bundle are set up in the groups' schema settings

#

but the build layout report will show you exactly what's being produced in the build

hybrid tundra
#

how to know when has this been loaded and what does it contain?

#

I haven't created ths

stuck plinth
stuck plinth
#

click on the group, the schema is what shows in the inspector

hybrid tundra
stuck plinth
#

look at the naming options, my unity is importing some big assets right now so i can't get a screenshot lol

#

it won't show you exactly where that particular bundle came from, that's more what the build report is for

hybrid tundra
#

there's no naming options

#

I can only see load path

stuck plinth
#

it's in there somewhere haha

hybrid tundra
#

build path

#

unique bundle IDs (which is disabled btw)

#

monoscript bundle naming prefix (disable monoscript bundle build is setted)

hybrid tundra
#

is it that?

stuck plinth
#

it's under advanced options

hybrid tundra
#

I'm fully lost

#

so is it the Addressables Groups window?

#

oh ok

#

I found that hardly

echo coral
#

I recommend "append hash to filename" so the group name is in the bundle name

#

but you only really need the hash versions for remote bundles or bundles not using the default local paths

hybrid tundra
pastel lion
#

Hi, is anyone familiar DOTS latios framework? I am trying to do something with it and facing some issues. Would really appreciate it

echo coral
hybrid tundra
#

rebuilding addressables is in progress

echo coral
#

then depends if addressables are built automatically with a new build then

hybrid tundra
#

the name

echo coral
#

check the docs about this setting and what you are doing if this is not changing things

hybrid tundra
#

well, maybe only at home

#

I will still try to rebuild it with using only filename

#

nope

#

going home

hybrid tundra
#

since then I realized I was idiot

#

because I already solved the optimization

#

I've written the addressable releasing "hack" I made to work only with one gameplay level and forgot to expand it

steel snow
#

with unity's mesh data api how do we update specific uvs or indices ? for the writable mesh data if you get the mesh buffer it doesn't come with the inital values of the mesh to edit

steel snow
#

not entirely sure how do to use this api properly to update specific indices

untold moth
steel snow
#

for me the user is adding/removing faces on mesh so im updating indices - if i have to keep grabbing the data updating and pushing it back won't that be a lot of performance hits

untold moth
#

I'd assume that unity is doing it the smart way and doesn't handle it in the managed memory.

steel snow
#

is there a direct way to copy the readonly data to the writing buffer like a memcopy or do i have to go through it in a loop

untold moth
#

I wonder if you can just modify the read-only data and pass it to the ApplyAndDisposeWritableMeshData

#

You'll need to play around with it and see what works, since it's not documented very well.

#

If you only just need to modify one mesh, I think just modifying it's triangles/vertices directly might be better.

steel snow
#

@untold mothwould something like this make sense:

            using (var input = Mesh.AcquireReadOnlyMeshData(mesh))
            {
                using (var output = Mesh.AllocateWritableMeshData(mesh))
                {
                    var uvs = input[0].GetVertexData<float2>(channel);
                    var buffer = output[0].GetVertexData<float2>(channel);
                    for (int i = 0; i < uvs.Length; i++)
                        buffer[i] = float2.zero;
                    Mesh.ApplyAndDisposeWritableMeshData(output, mesh);
                }
            }

will use job system for the for loop aswell for extra speed

#

i assume this is how unity expects us to do it - makes no sense to me that the writable mesh data doesn't at least start with the data from the mesh

untold moth
#

AllocateWritableMeshData doesn't take a Mesh

#

and you probably don't need to zero it out either.

#

It's not clear why you need to retrieve uvs either in your code. You never use them.

#

If you only need uvs for their length, there are probably better ways to do it.

#

I guess, you should start with explaining what exactly you're trying to achieve. Do you even need to do it via jobs at all?

steel snow
#

it does its just not documented

#

classic unity 😛

untold moth
#

In this case it might already contain all the mesh data.

steel snow
#

yeh going to test it now with some logs

#

the vertices seem to be correct but indices are not v.odd

steel snow
#

getting a weird error for this:

using (var output = Mesh.AllocateWritableMeshData(mesh))
{
    int start = GetTriangleStartIndex(column, row, triangleID, totalColumns);
    if (mesh.indexFormat == UnityEngine.Rendering.IndexFormat.UInt16)
    {
        var i16 = output[0].GetIndexData<ushort>();
        i16[start] = i16[start + 1] = i16[start + 2] = 0;
    }
    else
    {
        var i32 = output[0].GetIndexData<uint>();
        i32[start] = i32[start + 1] = i32[start + 2] = 0;
    }
    Mesh.ApplyAndDisposeWritableMeshData(output, mesh);
} //<--- error takes me here

ObjectDisposedException: The UNKNOWN_OBJECT_TYPE has been deallocated, it is not allowed to access it

#

oh wait im disposing twice i think

#

ok that was it ! never mind 🙂

hybrid tundra
#

we are abusing memory

steel snow
#

I only really worry about it in hot paths

tired fog
#

Is there any way i can sample normals from a mesh using their UVs?
The context is a height map mesh (no overhangs) that has been decimated. Therfore there might be vertex, vertex, no vertex, vertex if we look at it like a grid of equal distance. There are no holes, just some triangles bigger than others.

Is there any way for me to sample a position and a normal directly using a UV coordinates?

The target is to create a texture with information about the height and the normal of each pixel in the texture

ebon abyss
tired fog
ebon abyss
tired fog
#

I've seen methods using cameras to sample the mesh, but seems a bit overthetop

ebon abyss
#

You've got three arrays of note on a mesh. Vertices, triangles (aka indices) and UV's.

Vertices = vertex coordinates
Indices = index of the vertices in the triangle
UV = UV coordinates of a vertex (index maps to index in vertex array)

#

So for each pixel on your texture you'd somehow have to sample which triangle it falls on, then blend between the vertices that make up said triangle.

candid sedge
#

Hello can some one help me to make an AI car to race

hexed anvil
#

Anyone got any pointers on how i could more efficiently test colliders to see if they fall in the nodes of an Octree? Right now im using overlap box but unsuprisingly its very laggy, ive seen some things about using mesh vertecies to test against this but not quite sure how to go about it

hexed anvil
#

im using those to test colliders, the terrain

echo coral
#

Have you profiled this? Does this make use of burst and/or jobs?

#

share some code if you can

#

well designed axis aligned box overlap checks should be quick

hexed anvil
#

i profiled about 10k chekcs but honestly that seems a bit high so im not sure if it might be doing some unnecessarily

hexed anvil
echo coral
#

jobs can help if you need to do many checks all at once and burst will make things quicker and force you to use unmanaged structures

hexed anvil
#

its pretty basic

echo coral
#

how many allocations occur for 1 check?

hexed anvil
#

ill have to profile it again soon, i got dragged into some Overwatch 😅

echo coral
#

im confused how building an octree can be async as well

#

unless you are using worker threads

hexed anvil
#

yeah i was just trying things :(

echo coral
#

async is not a magic thing, its a way to better handle code that may not "finished" right now and needs a callback to continue after

#

e.g file io, networking, waiting for some time

hexed anvil
echo coral
#

yea you need to execute the code on another thread/worker thread and await the result to benefit from this
UniTask make this easy to do

#

you cannot use many unity functions on other threads however so may require some things to be done customly

hexed anvil
echo coral
#

you would need to do it all with your own structures, 3d box overlap checking isnt hard so its doable

#

(i dont see a reason for Bounds to not be usable however)

echo coral
#

the thread is what matters, async can be on the main thread just fine

#

Awaitable + UniTask offer functions to easily "swap" back to the main thread

ebon abyss
#

The problem with async is that it might call some things out-of-time.

#

Instead of during, say, the update loop

echo coral
#

if you use awaitable or unitask to delay its safe

#

it all uses the update loop and the unity scheduler

compact ingot
#

is there any particular reason why you are using an octree? is it optimal for something you want to do with your data? For AABB vs AAB lookups in a sparsely populated dataset a BVH is likely more suitable.

hexed anvil
#

Haha yeah, I wanted to make a fun fishing game but I was bored of these games just having the fish be random things you pull out, I wanted to use octree and a* to create a 3D navmesh for the environment

#

im not sure, I think i may have bitten off more than i could chew, I dont like giving up though

compact ingot
#

the fastest most readily accessible spatial lookup you have in unity is the BVH of the physics system.

#

an octree based a* sounds interesting but likely a yearlong project in itself to get it perform well.

hexed anvil
#

its always like that

#

ive got it set up so it generates an octree and a paths between nodes so something can navigate around it, but the octree takes about 8 seconds to generate and theres still issues with nodes being in inaccessible areas underneath the terrain and stuff

compact ingot
hexed anvil
#

i might have to shelve the idea though, I gave it a shot but i dont think ive got the goods to execute it

#

Thanks for all the input though, everyone!

dreamy edge
#

does it make sense to have a separate script for functions such as screen shaking, frame freezing and other utilities like that? Then in one script, like a weapon script, whenever a critical hit is performed, I have a delegate which I can subscribe a shake screen function to from the utility script

fickle mango
dreamy edge
#

thank you I’ll do that

crisp temple
wet burrow
#

How would I go about creating a signed distance field from a 3D grid of density values? I tried making this myself but it's not working very well, and I figured I'd ask around if there's an established way before trying to reinvent the wheel.

compact ingot
exotic trout
#

When vertex optimisation is done on a mesh, how is floating point imprecision considered when comparing verts for re-use? Is Mathf.Approximately good enough?

fallow echo
wet burrow
hybrid tundra
#

okay, so I still couldn't get rid of the optimization issues

#

any ide how to reduce D3D12GfxDevice memory consumption?

#

and ALLOC_DEFAULT

untold moth
# hybrid tundra any ide how to reduce D3D12GfxDevice memory consumption?
  • Use the profiler/native profiling tools to check what consumes video/GPU memory. Do you have a leak or just loading too much stuff?
  • Reduce the amount/resolution of textures.
  • Make sure that the textures are using compression.
  • Reduce the amount of meshes/LODs or their complexity.
  • Use more aggressive scene separation.
  • if possible implement texture/lod streaming.
  • Check what render textures are being created. Make sure there is no redundancy.
  • Check if there are any graphics/compute buffers created and that they are not oversized.
hybrid tundra
#

nothing is wrong with the D3D12GfxDevice memory reservation

#

I just always start to look at the memory profiler badly

untold moth
hybrid tundra
#

but even collecting them takes like forever

#

although at least I've found some managers which needs temporary, and they had static instances inside them

#

which were not freed up when scene unloading happened

untold moth
#

What's the point asking about ALLOC_DEFAULT then? This sounds like c++ side memory allocation.

cinder dirge
#

How can i disable mipmap on a texture2d save as .asset ?

untold moth
hybrid tundra
#

@untold moth can I load only the relevant TMP font atlases into memory? which I currently need. And the others could stay on the local storage

echo coral
#

tmp fallback stuff may get loaded always but otherwise id expect them to be loaded/unloaded when needed (and again, addressables should handle this where able)

untold moth
hybrid tundra
#

I would be happy if you could help me with that

#

because its not part of the leak itself, but a lot of font atlases are loaded unnecessarily into the memory

#

these are the references though

#

absolute zero idea how to resolve these

#

maybe its not even possible from here

#

do you know where's that fallback font asset table?

echo coral
#

project settings > TMP
or check the tmp folder

exotic trout
#

i think that stuff is in a resources folder? maybe Assets/TextMeshPro/somewherehere?

echo coral
#

yea its in a resources folder in there, you will find it

hybrid tundra
#

so I tried to remove fonts from fallback lists to free up memory

#

and it works quite well

#

but if I use the in-game language selector, even if I temporary load a font into the fallback font asset table

#

then it will stay in the memory

#

no matter if I clear up the fallback font asset table

#

do you have any idea how could it freed up?

untold moth
#

Typically this would also happen on scene load/unload, so unless you really need to free memory immediately it's better not to use it.

hybrid tundra
#

not yet, but that could work, especially now since I tried to load some fonts right now in a test class with Resources.Load

#

so that might work

#

well, 14 pieces of 4K and 8K textures would hold a lot of memory, so

#

I already tried to optimize those like a month ago, but then I didn't try to load only the necessary ones

#

I also added GC.Collect()

hybrid tundra
#

and also GC.Collect()

#

but still it stays in memory

untold moth
hybrid tundra
#

I load those fonts in my testing class I just created

#

I load those only temporarily

untold moth
#

Well, the profiler would tell you for sure.

hybrid tundra
untold moth
#

It would tell you why they are still in memory. Check the details.

hybrid tundra
#

that gameobject is created by the TMP itself

#

from the fallback list fonts

#

but since I clear that list

#

I don't really know why TMP won't recognize itself and just purge these things

untold moth
#

Because it probably doesn't have such functionality

hybrid tundra
#

and I don't have access to all TextMeshPro components

untold moth
#

That being said, I've never heard of tmp instantiating objects on it's own

hybrid tundra
untold moth
#

I see that some kind of tweening coroutine is also referencing it. As well as TMPro.TMP_SubMeshUI array.

exotic trout
#

is that in editor or in build

echo coral
#

Tmp does make sub game objects sometimes for drawing some text correctly, don't think its important here though

hybrid tundra
untold moth
hybrid tundra
#

from paths

#

to avoid [SerializeField] TMP_FontAsset usage

untold moth
#

And how are you unloading them?

hybrid tundra
exotic trout
#

(Also out of curiousity what unity version is this on?)

hybrid tundra
untold moth
hybrid tundra
#

newest TextMeshPro

#

any idea before I start to make a 30 min long build?

#

I've added these

hybrid tundra
#

still doesn't clean up the memory

untold moth
hybrid tundra
#

I'm constantly looking at the profiler

#

I don't even look elsewhere

untold moth
#

Does it say that it's loaded?

hybrid tundra
untold moth
untold moth
#

Then it's used.

hybrid tundra
#

obviously

untold moth
hybrid tundra
#

this is what I'm trying to do

untold moth
#

It could be that a new instance is loaded when by the TMP though. I'd make sure it's not referenced by anything at all before unloading.

hybrid tundra
#

by those gameobjects I told you

#

but I can't really do anything with those

#

TMP generates those

#

these are on those gameobjects

untold moth
hybrid tundra
#

what do you mean?

untold moth
hybrid tundra
untold moth
#

Or "can't you destroy it"?

#

That was a question asking if you can or can not destroy it.

hybrid tundra
#

but since the project has multimillion TextMeshPro components, I would avoid placing scripts onto those

untold moth
#

From the docs page it sounds like just something that would be used to render text, so I'm not sure why it's created automatically

hybrid tundra
#

will share an image in 1-2 min

untold moth
#

I'm going to sleep now, but I'll have a look in the morning.

hybrid tundra
#

I will also go home

untold moth
#

Ok...

hybrid tundra
#

@untold moth

untold moth
# hybrid tundra

I really doubt that's the default functionality of TMP. Maybe there's some code in the project instantiating these?

hybrid tundra
#

and its because of these are in fallbacks

exotic trout
hybrid tundra
hybrid tundra
echo coral
#

"com.unity.textmeshpro": "3.2.0-pre.12"

hybrid tundra
#

the whole TMP version doesn't work

#

can't render the characters

#

I can only see different sized colored rectangles

#

at least the original version worked

#

with the exact same fonts

echo coral
#

I can only presume some materials are broken and perhaps need regenerating. I use 3.2.0 just fine in a few projects

hybrid tundra
#

and I'm already working (again) for 9 hours

echo coral
#

find the tmp font asset, if its static do "update atlas texture" and regenerate it

#

You can check the textures inside fonts too if you need to

hybrid tundra
hybrid tundra
echo coral
#

the material must be half broken then. reset it and check again

hybrid tundra
#

I will switch back to the original TMP

hybrid tundra
#

I have only 1 month left, and I still would need to do some other things

#

but until now I don't really have too much results with this task

#

already invested ~2 weeks or more into it

dusty cove
#

in UIBuilder I'm able to bind a slider to a scriptableObject float value I have (volume),
and when confrigured with "two way" binding mode I see the value change in the SO when I change the slider, and I see the slider change when I update the value in the SO via the inspector.

but I don't understand how my volume service is supposed to "listen" for changes made to that value?
how can I "hook" my service to the value change like UIToolkit is doing?
(Unity 6.1)

marble otter
#

Guys, have any updated documentation about Mediation Ads?

#

The documentation on their website is all obsolete

#

And their sample demo too =/

marble otter
echo coral
#

And you can correct the namespace for most things I think

#

Hopefully they do update this bit

marble otter
#

I tried to see from their sample, but their sample still does it that way too

#

oh, my bad..

marble otter
#

using Unity.Services.LevelPlay the obsolete disappears

#

thank you ma frendo 😄

echo coral
#

Yea then do that, I did notice some as object events have the old one but should mostly work fine

marble otter
#

without legacy formats

echo coral
#

If you don't need to use a legacy way of showing ads then yea

heavy blade
#

i'm working on this system for allowing certain actions the player can take to "occupy time" of the two first-person arms, and certain actions can only be completed given the left, right, or both arms aren't busy with another action. right now i'm just using static variables for the timers on the left and right arms, so it's pretty coupled with other scripts. i could spend some time to make it a slightly more complicated system but decoupled, or just leave it as is since not a ton of scripts are gonna be interacting with this

#

in the longrun is it more worth it to set up more clean but complicated architecture? or just kinda use what works if the scope isn't huge

echo coral
#

Having a timer or delay to perform an action is a common thing but it may be easier if you simplify it and avoid using static variables for this state.
You don't need the bool as if the timer is <= 0 you know it has run out

#

Also if this is something related to an item/object then perhaps it can be stored and checked in the item itself?

fallow echo
untold moth
# hybrid tundra but until now I don't really have too much results with this task

Are you sure tinkering with the fonts is really gonna help? You never actually explained what the issue that you're trying to fix is and it's context. Was it am OOM crash? Then did you inspect the memory at the point of the crash? What's taking most of it? Is it actually an OOM? Or are you confusing some other issue with it?

exotic trout
#

Maybe I have too much blind faith but I feel like I kinda trust TextMeshPro to do a decent job at managing its own necessary memory?

#

(moreso the usage of assets rather than the developer provided assets themselves of course)

echo coral
#

There are issues with the settings asset only working via Resources meaning it doesn't play nice with addressables but I think you can work around that by modifying it after its loaded

hybrid tundra
#

even if there's a freeze, I can't make a snapshot from that time

#

the unity editor simply crashes during making snapshot, if I try to do that

#

yes, its OOM crash

#

previously the most of the memory was textures. but by fixing this font thing, now the shaders are taking the most of the place

#

and the game is much more stable than it was 2-3 weeks ago

#

there was a map I couldn't even loaded back then

#

then I could load that map, but I couldn't return to the main menu

#

now I can go back and forth without OOM crash

#

but when I played that map for a longer period of time, OOM happened again

#

with this font modification, I hope this will be solved finally

hybrid tundra
#

how is this even possible?

echo coral
#

how tf does that font have 4 64MB textures

hybrid tundra
echo coral
#

understandable

#

I work with mobile so I have mine set to 2k max

untold moth
#

Otherwise there's no point to your fixes. You might be fixing things that are not even related to the cause.

untold moth
hybrid tundra
#

if stabiliy got improved, I would highly suspect I'm doing something right, no?

untold moth
#

It really sounds crazy to me that you didn't do anything to investigate the root cause properly.

#

I assumed you're acting from the understanding of what exactly fills the memory at crash time.

hybrid tundra
#

well, the root cause is that its a spagetti code

#

there's no one single issue originating

untold moth
#

I don't think so. That's a cheap excuse to not do proper diagnostics.

hybrid tundra
#

the whole code base would need a proper refactoring

hybrid tundra
#

and I couldn't really figure out anything useful from it

#

yes, maybe someone more experienced in profiling could figure out something

#

but I couldn't

#

and I can't share the screenshots from those, because its NDA tools

#

all I could see is that the memory usage was always around top

exotic trout
#

what is top

hybrid tundra
#

around the maximum available memory

exotic trout
#

(which is)

hybrid tundra
untold moth
hybrid tundra
untold moth
hybrid tundra
#

at all

untold moth
#

You only need to read the section related to using the mentioned tools.

untold moth
hybrid tundra
#

and I couldn't get any useful info from it

#

I played with it like for a few hours, and I ended up nothing new

untold moth
hybrid tundra
#

maybe the issue is that I'm not a native english speaker, and I struggle to understand words inside this profiler

hybrid tundra
untold moth
#

Yes, timeline is usually what you need to look at. Then you can select specific points in the timeline to investigate further.

hybrid tundra
#

the title says memory performance

#

there are things like total accessible memory, total accessible optimal memory, peak used memory

#

etc.

#

I don't even know what these mean

#

total physical page allocations

untold moth
#

Anyways, you could also try using the regular unity profiler(not the memory one) with the memory module and reproduce the crash. It should keep on recording until the very crash.

hybrid tundra
#

peak used memory

#

title free list

#

these don't tell me much for me

untold moth
hybrid tundra
#

maximum allocation size, minimum free depth, allocation count, free count

hybrid tundra
untold moth
#

Max allocation size sounds like a relevant metric.

hybrid tundra
#

why?

#

I checked the doc again

#

this doc again assumes that I already know everything related to memory, and I should just use the tool

untold moth
#

Because it's telling you the max allocated memory at a point of time?? I don't know for sure. This would be heavily context dependent and covered in the documentation.

hybrid tundra
#

it doesn't try to teach me the basics

untold moth
hybrid tundra
untold moth
hybrid tundra
#

memory profiler can at least identify unity related stuff

#

but this native thing won't be able to tell me those I think

untold moth
untold moth
exotic trout
#

not to throw another potential problem in the mix, just a thought

hybrid tundra
#

@untold moth there's a leak for sure, but not the leak is the worst. The game itself uses too much memory even when only any gameplay map gets started

#

so even the leak would not cause that much issue, if the overall memory reservation would be much less

exotic trout
#

what is too much

hybrid tundra
untold moth
hybrid tundra
#

I didn't write those data down anywhere

exotic trout
#

but like

#

what metric defines if you have successfully completed this work?

hybrid tundra
#

and the game is constantly eating around 10 gb on all platforms

untold moth
hybrid tundra
untold moth
hybrid tundra
#

it should not always lurk around the very edge

hybrid tundra
#

at least I understood memory profiler much better than the native tools

untold moth
#

So far you were targeting very small things from what I've seen though.

#

How much memory is occupied by textures? By meshes?

#

These 2 usually eat most of the memory.

exotic trout
#

what happened to this

untold moth
#

If there's something else, it's likely an issue.

hybrid tundra
untold moth
#

If it is textures, you can reduce the base min mip level. This is very common on consoles. And it would solve your issue immediately.

#

Consider texture streaming as well

hybrid tundra
#

already did that weeks ago

#

both texture streaming

#

mipmap resolution

#

and it did solve a lot about stability

#

but textures looked horrible, because it decreased resolution everywhere

#

then I only decreased resolutions where it was not recognizable

#

also disabled Read/Write

untold moth
#

And you're still getting crashes, meaning it's a memory leak.
So either use the native profiling tools, or at least the timeline profiler(the regular one) with the memory module and reproduce the crash. Then look at the latest slice of data.

#

Or monitor the memory consumption and pause execution when it's about to reach the limit. Then make a proper capture.

hybrid tundra
#

memory is not increasing by 1 kb each time

untold moth
#

Well then monitor it and see how it increases. At what timings. Let the game run in the heavisets scene for some time, then look at the profiler timeline.

#

It shouldn't increase in the middle of a scene when you're not doing anything. If it does, that's the leak.

hybrid tundra
#

@untold moth what I've seen is that after I fixed 90% of texture memory leak (which was huge), I still had native Reserved memory leak (around 1 gb), that was the ALLOC_DEFAULT thing I mentioned days ago.
I think - but I'm not sure - this was because of the million static fields holding stuff in memory. There are gameplay related codes using static fields. But I couldn't identify 1 thing which holds a lot of memory. Instead there are literally like 100 or more which does this. And unfortunately I have no time enough to check and fix all of these. Especially since I can easily f*ck things up if I don't understand how and when to set something to null.

#

about texture memory, I measured that and the difference was not much after my optimizations

#

I mean I solved the texture memory leak

#

and it was mostly because of the addressable bundles were not released correctly

untold moth
hybrid tundra
#

is it still leaking? yes. But that's not much anymore, and I don't really have any idea how to release those, because some of them were held by fields I have zero idea how to set to null without f*cking things up

untold moth
#

Static fields by themselves are unlikely to cause a leak.

hybrid tundra
#

I can only see its around 1 gb and nothing else in Memory Profiler

untold moth
#

The issue likely happens when this reserved memory is all getting used and the project still needs more.

#

Which is why I'm telling you to profile at crash time.

hybrid tundra
untold moth
#

Or even better - learn to use the native tools

hybrid tundra
#

I really don't have time to learn everything about memory, because I should already know these

untold moth
untold moth
#

You can probably spend a day or two to learn all the underlying concepts properly

#

And then solve the issue quickly.

hybrid tundra
#

it would be great to not panicking constantly

#

first of all

untold moth
#

Indeed

#

The normal dev workflow is:

  • investigate
  • learn/research
  • investigate
  • fix
  • evaluate
  • repeat

You seem to have skipped several of the steps and got stuck in a counterproductive loop

#

There's no point panicking. The issue is not gonna solve itself. And the shortest path to success takes some time.

#

Cutting corners is only gonna make it worse.

hybrid tundra
untold moth
#

There's a lot of details that we don't see, so it's hard to make any proper conclusion.

#

But it does feel like you never investigated the actual cause of the issue.

hybrid tundra
#

I could have explained everything better with images I made from memory profiler from the start

#

but its time consuming to make screenshots, because I don't have Discord installed on my company PC

untold moth
#

And started jumping to conclusions based on only assumptions

hybrid tundra
#

so I usually just jump back and forth from company PC and notebook

untold moth
#

Unconfirmed assumptions are the the worst enemy of a programmer.

hybrid tundra
hybrid tundra
#

those were not uncomfirmed assumptions

#

and I know for sure (from measurements) that they are still leaking

exotic trout
#

if they are not unconfirmed why do we need to trust you

hybrid tundra
#

but I found it extremely hard to fix all of the leaking textures from the References window

hybrid tundra
exotic trout
#

also, no offense whatsoever, why would we trust you when you are very new to this

untold moth
#

Like even now, you're saying that there is a leak for sure, but you never shared any definite proof

hybrid tundra
#

1000~ ish texture cound when I'm in main menu

#

1400~ ish, when I return from gameplay to main menu again

untold moth
hybrid tundra
#

and I cleared up the 400

untold moth
#

What about the third time?

hybrid tundra
untold moth
#

This doesn't prove anything

hybrid tundra
untold moth
#

It could stabilize after the second transition.

#

A leak is when it would increase every time you repeat that action

hybrid tundra
#

it gets increzing though

#

so its leaking

#

third time its leaking

#

forth time its leaking

#

not much, but its leaking

#

but even those 400 is too much, because it should be the same

exotic trout
#

it's not about how much in isolation, it's how much per same loop

untold moth
hybrid tundra
untold moth
exotic trout
hybrid tundra
#

I compared snapshots with the Compare Snapshots button....

#

there was 1 gb difference in textures

untold moth
untold moth
hybrid tundra
#

that was already much

untold moth
hybrid tundra
#

yeah

#

this is what I try to say

untold moth
#

So that is not related to a leak

#

Different issues require different solutions.

hybrid tundra
#

isn't it a leak if main menu by default doesn't have FX and stuff, and when you return from gameplay, there is?

untold moth
#

This is not called a leak

#

I mean, technically it is, but not a permanent leak.

#

Now crashing in the middle of the scene after it's running for a while does sound like a real leak

hybrid tundra
#

in the beginning this much leak was already enough to break the game

#

and this is what I've solved until now

untold moth
#

Fair enough. But I understand that you're dealing with a different issue now

exotic trout
#

dlich mentioned it before but very curious what the texture counts for in level/game 1, in level/game 2 and main menu 3 are

untold moth
#

The way I understand it now there are 2 issues:

  • you are in the middle of porting the game to a platform and just discovered that you are way over the memory budget.
  • you have an actual leak over time in some scene.

The way you explained the issue initially mixed these 2 separate issues into one and made it difficult to provide you with a proper solution

hybrid tundra
#

I try to solve both at the same time

untold moth
#

That's not correct. You don't try to solve both at the same time.

hybrid tundra
#

ok 😄

untold moth
#

You shouldn't I mean

echo coral
#

Im going to guess addressable issues have not been addressed fully so that doesnt help but if over memory budget then you have to cut down or remove things.
Chinese font too big? Lower its texture res and character size (to fit the same in a smaller texture)
Too many textures? remove some effects on this platform and suck up it looking worse or combine certain textures by using all channels (avoid RGB tex just for roughness/smoothness for example)

hybrid tundra
#

I created a separate manager to collect all AsyncOperationHandles

#

and I collect them based on the active scene

#

and I release all of them which were created on certain scenes

echo coral
#

But what happens then if you keep loading things in a scene for ages?

hybrid tundra
#

at least I can't find any assetbundle references in the Memory Profiler for the textures left in memory

#

and 90% of them gets cleared

hybrid tundra
echo coral
#

I only point this out in case you say show effects temporarily/rarely but their assets remain loaded

echo coral
#

Then that illustrates that in some places, releasing loaded assets when destroyed/no longer used will help free resources

gusty moon
#

Is the heightmap data pulled from the Terrain's heightmapTexture field and GetHeights just poor?
Something like this
var data = terrain.terrainData; int tileRes = data.heightmapResolution; var heights = data.GetHeights(0, 0, tileRes, tileRes);

I've spent the past week fudging around with trying to map the terrain heightfield from unity, onto a physx scene.

On slopes I'd see differences of up to 0.5 + units.

Only after i created my own exporter that raycasts every point in the world, then generate my own heightmap from that did it end up matching. This takes quite a long time though.

Am I missing something with the heightmap? Does unity do something special to it when actually mapping it to physx? I know the sample height gets ran through bilinear interpolation, but I can find nothing about the actual heightfield collider that unity maps.

#

And the terrain in question was generated via the terrain tools in unity, not one I imported manually.

#

Curious, anyone else has worked on any server authoritive movement? What did you do for your terrain if not using the GetHeights/heightMapTexture?

hybrid tundra
#

Would it be an acceptable solution if the player needs to restart the game when language switching happened?

#

because I can't get rid of the unused 700 mb long font texture atlases other way

#

from memory

ebon abyss
#

I think when I tried to play the last Call of Duty it restarted several times before I was able to play 😄

hybrid tundra
#

hmm ok

untold moth
#

You should check the platform technical requirements. They might have a rule against doing something like that.

uneven dove
#

having a bit of an issue coding for my own game engine, so in one of my scripts called RagdollXEditor i have a namespace Ragdoll. in my Program.cs i’m having an error with using Ragdoll; that’s not my main problem, my main problem is this. “var editor = new RagdollXEditor(GameWindowSettings.Default, nativeWindowSettings);
editor.Run(); So for the RagdollXEditor thing above it’s getting an error saying it couldnt be found i’m using vs code. C# OpenTK and ImGUI.Net

echo coral
uneven dove
#

i have no idea

uneven dove
#

i just need help😭

#

i’ve even tried the smartest C# ai as my last resort and he couldn’t fix it

humble leaf
uneven dove
#

yea prob

#

it was for my ui

formal nexus
#

So im working on a 2D game and I have a "public class ContextTrigger : MonoBehaviour" that i inherit to another class "StaticNPC" which is basicly a conversation starter when the player walks into a triggerzone and presses up.

here below is the ContextTrigger base. it sets a ACTION that gets called when the player steps into the trigger area. this action is ActivateInteraction();
BUT this does not Set the Override version of the ActivateInteraction(); is there a way of triggering the override version from the base script? or do i need to re-think parts of this code?

    {
        if(other.gameObject.CompareTag(TAG))
        {
            // Get the player reference for this specific trigger instance.
            _playerReference = other.gameObject.GetComponent<Player>();
            
            if (_playerReference != null)
            {
                _playerReference.ContextStore = () => ActivateInteraction();
                Fade(true);
            }
        }
    }
    
    public void OnTriggerExit2D(Collider2D other)
    {
        if(other.gameObject.CompareTag(TAG))
        {
            // If the player that is leaving is the one this trigger is tracking,
            // and that player's current interaction is set to this trigger, clear it.
            if(_playerReference != null && _playerReference.ContextStore != null)
            {
                _playerReference.ContextStore = null;
            }
            Fade(false);
        }
    }
    
    /// <summary>
    /// This method is called by the Player. Child classes will override this
    /// to define what happens on interaction.
    /// </summary>
    public virtual void ActivateInteraction()
    {
        Debug.Log($"Interaction activated on {gameObject.name}, but no action is defined in the child class.");
    } ```
echo coral
#

If i were to do this, id just assign the class ref instead of the function to a delegate. An interface may be a better choice for this.

formal nexus
echo coral
#

Action is just a delegate type made for you, won't make a difference

formal nexus
#

Hnmmn

echo coral
#

Did you use a debugger then to verify what you saw? virtual functions should not work as you described, Hidden functions can

formal nexus
#

I have not but will do as soon as I'm not about to fall asleep 🙃 thank you BTW. I will look at the debugger tomorrow

jovial plover
#

Hello unity community. I got stuck on something for 2 days so now I'm here asking for assistance.
I am using a unity hexagonal tilemap. I want flat-topped hexes, which I assume is my downfall, because unity uses really weird offset-coordinates, and also flips the x and y axis, since it isn't confusing enough.

Attached is a small preview of coordinates.

I now already managed to implement A* pathfinding somehow and it works, so I'm not touching it anymore.

The issue comes next. For projectiles, I want to implement a "line of sight". This function would receive a start and end position, and return a list of positions that are touched by a line drawn between them.

This does sound pretty easy, but a mix of unity confusion and skill issue led me here.

https://www.redblobgames.com/grids/hexagons/ this document helps in general with hex grids

https://zvold.blogspot.com/2010/02/line-of-sight-on-hexagonal-grid.html This document describes the exact behavior that I want, even has another source with some more descriptions of the algorithm, and even though I now understood how this adaptation of the Bresenham line-drawing algorithm is supposed to work, I cannot get it running.

Do you have any tips/more documentation on this problem?
Should I just cut my losses switch to a self-managed hex-grid? Any good versions of that?

sly grove
# jovial plover Hello unity community. I got stuck on something for 2 days so now I'm here askin...

I too have gone through the pain of doing exactly what you're doing - translating redblob games hex algos into Unity's cell coordinate system. It sucked.

What you need basically is a function that takes a coordinate and can give you a specific neighbor tile in a chosen direction. Once you have that, then you can follow the redblob algoirthm exactly.

For example they have stuff like this in the code examples:

get UP_LEFT hex```
You need to write a function that can do that for all six directions (UpLeft, Up, UpRight, DownRight, Down, DownLeft) for a given hex, then just write the code as per their algoirthm using that function
#

The way I managed to do things in my game was just to write functions to convert unity coordinates to redblob's cube coordinates and back. Then i was able to use the algorithms from redblob directly.

#

if you do that conversion - you can use the functions from the Neighbors section of redblob to get neighbors, do line drawing (which would work for LOS) etc..

jovial plover
# sly grove I too have gone through the pain of doing exactly what you're doing - translatin...

something like this?

    private static readonly Dictionary<EDirections, Vector2Int> evenColDirections = new()
    {
        { EDirections.NW, new(0, -1) },  { EDirections.N, new(1, 0) },  { EDirections.NE, new(0, 1) },
        { EDirections.SW, new(-1, -1) }, { EDirections.S, new(-1, 0) }, { EDirections.SE, new(-1, 1) }
    };
    private static readonly Dictionary<EDirections, Vector2Int> oddColDirections = new()
    {
        { EDirections.NW, new(1, -1) }, { EDirections.N, new(1, 0) },  { EDirections.NE, new(1, 1) },
        { EDirections.SW, new(0, -1) }, { EDirections.S, new(-1, 0) }, { EDirections.SE, new(0, 1) }
    {


    private Vector3Int OffsetToCube(Vector2Int offset)
    {
        int x = offset.x;
        int z = offset.y - (offset.x & 1);
        int y = -x - z;
        return new Vector3Int(x, y, z);
    }
    private Vector2Int CubeToOffset(Vector3Int cube)
    {
        int col = cube.x;
        int row = cube.z + (cube.x & 1);
        return new Vector2Int(col, row);
    }

Maybe I need to redo the conversion functions, and then translate more closely. I've tried, but every time I get back really wired data, an then am unsure what the issue was. I guess I need to go a bit slower.

sly grove
#

Not sure, I wouldn't be able to tell you off the top of my head. I recommend writing unit tests for it to make sure you are covering all the edge cases, this stuff can get very confusing.

#

ChatGPT may be helpful here too

jovial plover
#

Thanks. Did using unity hexes cause any more issues down the line?

jovial plover
sly grove
#

Once I had the conversions set up (sorry it was an old project and I lost it) then I had no issues with the coordinate systems anymore

jovial plover
#

no worries. I will try again tomorrow...

steel snow
#

Tryign to create a texture array for normals but the normals seem to change colour in the array, is that normal? They are marked as normals before adding them to the texture array, they are purple in my asset folder but in the array they are brown looking

#

i assume its just how unity displays texture arrays but im not sure

#

oh just noticed the albedo is also the wrong colour in the array 🤔

untold moth
#

Funny, but I'm working on a material merging tool that also uses texture arrays right now.

#

In unreal engine though

steel snow
#

what is the correct format for normal textures? i fixed the albedo one by using RGBA32

untold moth
exotic trout
steel snow
#

@untold moth this is what i do

albedoArray = new(_textureSize, _textureSize, textureSets.Length, TextureFormat.BC7, true);

normalArray = new(_textureSize, _textureSize, textureSets.Length, TextureFormat.BC7, true, true);

for (int i = 0; i < textureSets.Length; i++)
{
    var set = textureSets[i];
    AssertIsValid(set);
    for (int mip = 0; mip < set.Albedo.mipmapCount; mip++)
        Graphics.CopyTexture(set.Albedo, 0, mip, albedoArray, i, mip);
    for (int mip = 0; mip < set.NormalMap.mipmapCount; mip++)
        Graphics.CopyTexture(set.NormalMap, 0, mip, normalArray, i, mip);
}

albedoArray.Apply(false, true);
normalArray.Apply(false, true);

albedo works fine, normals however the array does not show purple maps like you would expect its more orange looking

#

this is how it looks

untold moth
#

I'm not sure bc7 is an appropriate compression format for normals

#

Compare to the original textures.

steel snow
#

so im very confused

untold moth
steel snow
#

Maybe but I see no texture format for it so I'm unsure

untold moth
steel snow
#

No seems not

steel snow
#

Oh different enum, why do they have two enum types

untold moth
odd turret
#

I'm trying to use Unity.Serialization to deserialize a JSON file
I have a custom IJsonAdapter for one of my types and inside of it I'm trying to trigger the default deserialization for another type, which is one the values inside a dictionary:

            SerializedMemberView firstVersion = versionsObject.First();
            if (!int.TryParse(firstVersion.Name().ToString(), out int firstVersionKey)) {
                throw new FormatException($"Invalid version key: {firstVersion.Name()}");
            }

            T? firstVersionValue = context.DeserializeValue<T>(firstVersion.Value());

and this is the JSON:

{
  "versions": {
    "1": {
      "attackAllowed": true
    }
  }
}

the firstVersionValue object is created, but not initialized with the correct value (attackAllowed = true)
any clues on what could be going on?

hybrid tundra
#

why this window always come up like 4-5 times, when I just try to write scripts?

#

its extremely annoying

#

and causes the whole sln to reload multiple times after each other

fickle mango
hybrid tundra
echo coral
#

id presume the connection settings are wrong so it keeps asking (or the connection fails/is refused/is blocked)

untold moth
hybrid tundra
#

if I make a build, it pops up

#

if I make a new script, it pops up

echo coral
#

Is there some unity svn plugin triggering this, or it detecting file changes ?

untold moth
#

I'd investigate if it comes from the ide or unity first. In both cases I'd avoid using the plugin(as I heard it's terrible) and just use the standalone client.

hybrid tundra
#

no idea

marble otter
#

hey @echo coral do you know if i can test my ads with mediation in unity simulator?

echo coral
marble otter
#

I'm using android simulator They have a test suit that already worked on the physical device and emulator (bluestacks), but I would like to have the debugger to do some tests so I wanted to run it on the Unity simulator.

#

This test suit don't work in simulator and I don't know if i've to do some additional configuration

echo coral
#

what is "unity simulator"

marble otter
echo coral
#

there are android emulators

marble otter
#

is that simulators

echo coral
#

yea thats the unity editor my guy

#

simulator just changes the screen size + safe area emulation

marble otter
#

I'm going to use Android's logcat and Bluestacks to test it, so it would be cool if these things worked in the "editor", it would save a lot of time.

echo coral
#

You can use the level play test suite to show ads easier (if using it) and you can use logcat OR the unity console on dev builds to see logs
you can also enable debugger support for dev builds

marble otter
#

yep, i'll do that on bluestacks, bcz in editor the test suite dont work

#

and sorry for my bad english haha

echo coral
#

Yea dont expect any of this to work in editor unless it states it can show ads on desktop

formal nexus
#

i think im losing my mind or just being thick. i have StaticNPC assigned to a Gameobject in my unity scene StaticNPC inherits ContextTrigger and when my player passes into the collision2d trigger it should trigger the protected virtual void OnPlayerEnter(Player player) method which i have done a override on in StaticNPC. but it triggers the base class version... why is this?

echo coral
#

So StaticNPC.OnPlayerEnter() is not called?

formal nexus
#

no it is not

echo coral
#

to make sure you arent making a mistake, change it to abstract in ContextTrigger (will require ContextTrigger to be abstract too)

#

There is no good reason I can see why this wont work, its virtual so the override will be called (dynamic dispatch) for an instance of StaticNPC.

formal nexus
#

ok... found the issue. i load chunks of levels into the main scene and where i was trying the trigger the staticnpc trigger was not correctly set up and there was a base contexttrigger gameobject at almost the same place that i never noticed until i tried setting ContextTrigger to abstract class and got a error message when it was loaded into the scene. i was immensely confused about why things where not working correctly... #"%!)¤!&#))¤%/

#

@echo coral thanks you, managed to help me find my brain 😄

echo coral
formal nexus
modest solstice
#

for regular models that are imported into a unity project, is it possible to write like an asset preprocessor script where I can actually modify the vertex attributes of an imported mesh?

#

for example, I have some mesh assets that I might want to make lighter weight in terms of memory

#

and for vertex attributes, I would like to take the mesh of this imported model and bump all of these from float32 to a half float16

modest solstice
long ivy
modest solstice
long ivy
#

the mesh seems to be readable regardless of the read/write flag during this step, which makes sense to me

modest solstice
#

I’ll go ahead and give it a shot and give ya a holler in case not

wind temple
#

I got a 150-line Python script that scrapes data from the Jikan API

#

can i post the whole thing here

humble leaf
wind temple
#

Yes, it's for a card game i'm making in unity

humble leaf
#

Unless it's directly in editor, related to Unity, then it's not appropriate here. If you need python help, find a community for that.

wind temple
#

Oh, I understand then

#

Appreciate it

shadow nebula
#

I have most of my balancing information in the form of scriptable objects (some are on prefabs in the resources folder). To help my game designers, I want to ship them the finished binary of the game and have the balancing in a separate json file, that is used to change the scriptable objects (and probably the prefabs) data. This seems like a common problem. Are there standard strategies to handle this case? What is a good system? Addressables, or too much work for that? Or do I need to write a custom C# script, that runs before anything else? How do I set this up?

tall ferry
shadow nebula
#

What would speak against changing the SO's?

tall ferry
# shadow nebula What would speak against changing the SO's?

changes dont persist in a build and arent guaranteed to persist throughout one session. If your scriptable object gets unloaded, it will reset back to the values defined initially. At least thats how it works from what ive read.
I've never seen talk about doing this on prefabs so im not sure if this works the same.
it's best if you can avoid doing this

shadow nebula
#

Oh, interesting. Thank you!

solar mist
#

Hello there!
I started having an issue out of nowhere.
I am using the latest unity 6 lts. and when I click play, Unity just freezes and becomes non responding. No error messages, nothing. Just complete freeze to the point where I have to end the task on windows.

Any ideas???

Thanks!

long ivy
#

Likely an infinite loop in your code. What have you done to debug it?

solar mist
#

I tried debbuging and adding breakpoints and all... reseted unity a bunch of times... updated burst... ehehhe

#

at the end I just reverted to my last commit, which was fine.

#

luckily I commit very often and was much to redo.

long ivy
#

well it does sound like you had an infinite loop somewhere if reverting fixed it, and just didn't put a breakpoint inside the loop so it never got hit

#

I don't know what you expected tbh, you provided virtually no info besides Unity version

solar mist
#

not following... I even thanked you buddy. Its good.

onyx violet
#

Hello there
does anyone know a way to check how much memory each part of a projects code takes in a build?
We've run into a pickle on consoles where "faster runtime" causes the build to hit a memory limit
And since we cant really look into a console build that well we wanted to check on PC first

sage radish
#

Newer Unity versions will show more details with this package.

echo coral
#

2021 is limited, should all work 2022+

untold moth
stuck plinth
#

turning on "faster runtime" disables one huge optimization in how code is generated for generic type instantiations, so you'll likely see a huge increase from that

#

Note that when the “Faster (smaller) builds” setting is enabled only the single fully sharable version of generic code is compiled. This reduces the number of methods generated, reducing compile time and build size, but comes at the expense of runtime performance.

sage radish
stuck plinth
#

yeah, but that's more a regular memory issue - due to [mystery console OS reasons] the binary size specifically is very important

echo coral
stuck plinth
#

assets aren't included in the binary, just code

echo coral
#

depends on the platform if its 1 "blob" or many files

#

e.g. android, ios

stuck plinth
#

i'm pretty sure even on those platforms there's a separate binary, like android archives do have a binary file in them separate from the assets

echo coral
#

things other than code will be loaded into memory such as audio so i dont see the problem with checking more than code

#

regardless they can use the tools avaliable to find out more regardless of what i say 🤷‍♂️

stuck plinth
#

this is about a console platform though, and without getting too deep into it, i'm pretty sure this person is asking this question specifically because binary sizes matter on that console

#

it's not just a total memory usage or package size problem

echo coral
#

Then my suggestion is to reduce il2cpp options such as stacktrace info level + what others said

#

It is possible to provide compiler options for other platform compilers too so this could also yield improvements by reducing in lining for example (or ensuring debugging info is stripped as this may not always be the case)

hybrid tundra
#

why is that incremental build takes 10+ minutes to finish?

#

I'm 100% sure I didn't change that much since the last build

mighty shore
#

Question using StaticBatchingUtility.Combine to combine meshes to boost the FPS

#

I thought about using "Graphics.DrawMeshInstancedIndirect" to render each individual faces but I can't do it because I need to modify each vertex to smoothly express the terrain

#

I don't think I can further optimize these terrain unless I do some crazy compute shader thinging and maybe send terrain info to gpu and generate vertexs from there and stuff. Let me know if I am missing anything

#

2nd issue I have, entities, I have lots of entities in my game and they may MOVE or not (trees and plants do not move but birds might move)
I intend to use simple 3d models (as you see in the image) to represent objects in the game.
I believe in this case, the best approach is to use Graphics.RenderMeshIndirect for trees grass flowers and such (even for moving ones perhaps)

#

SOME entities have very individual distinct look (my game is basically 3D Rimworld/DwarfFortress) and I believe for those distinct entities, my best option is just rendering them without tricks.

#

Any feedback is appreciated, I really need to work on this because now I am appraoching like 3M tris (tears) @cobalt ember

untold moth
#

Don't try to solve problems that you don't have

mighty shore
#

yup

#

the screenshot above is scaled down size of the world

untold moth
mighty shore
#

let me re-do the rendering

untold moth
mighty shore
untold moth
#

Which is what you want to investigate.

mighty shore
#

this is only half of the world unfolded and 4 M tris and dropped 100 FPS from 600 FPS

#

my game is literally not much going on right now except this, this is the issue

untold moth
mighty shore
#

yes both of them are issues

#

and they are related to each

#

I feel like I am just re-stating the problem question I already did

untold moth
#

Well, no. You started jumping to conclusions. And bringing up manual draw calls from code.

Anyways, if you're using urp 17+ with forward + rendering path, and have a lot of repeating models/materials, using the resident drawer feature would basically solve the draw call count issue. That's a CPU bottleneck.

Vertex count can only be solved by using some form of LODs or limiting the drawing distance(possibly by layer, so that smaller objects are not drawn after a certain distance). That's a GPU bottleneck.

tacit harbor
#

How to minimize untracked memory? and what is it ?

untold moth
tacit harbor
untold moth
#

Unity likely used it at some point, but then freed it. Instead of releasing it to the system entirely, it keeps it reserved, to naked future allocations faster.

#

Assuming it is indeed reserved memory.

#

Using PS4 native tools(memory analyzer) should show more info.