#archived-code-advanced

1 messages · Page 76 of 1

scenic forge
#

await it.

cloud crag
#

but it method is void

#

should I make async void?

#

because it is called like regular function

cloud crag
#

not that easy O-o

sage radish
#

The problem is that Unity is asking for a lot of samples from your callback when you create the audio clip, and on the main thread. If those samples aren't ready, like if you're still downloading or processing them, Unity will stall.

scenic forge
#

You are doing it wrong, using (var res = await synthesizer.StartSpeakingTextAsync(speakMessage))

cloud crag
scenic forge
#

Tbh this is basic async/await, you should take time and properly learn it.

sage radish
# cloud crag Yeaah. exactly

So I would suggest you download the data into your own MemoryStream, wait until you have a decent amount of samples, then create the AudioClip where you copy from that memory stream in your callback. Best case scenario, your buffer will always have the amount of samples Unity asks for so it doesn't need to wait at all.

cloud crag
#

if I do .Result in using() it works, not here

scenic forge
#

res is already the result, you don't need .Result anymore...

cloud crag
cloud crag
#

?

#

but now I see:

#

UnitySynchronizationContext.ExecuteTasks() [Invoke]
1481.71ms

#

But I saw this yesterday too.

#

with that code before changing

#

Read Data takes time I think

#

But, how to solve that UnitySynchronizationContext.ExecuteTasks()? weird

sage radish
#

If the stream is from a web download that is still downloading, then there's no amount of await that will solve this.

#

Unity is calling your callback on the main thread, waiting for it to finish giving it all the samples it needs. If they're not ready, it will have to wait and stop the whole game until it's ready.

cloud crag
#

Aha. but for downloading should not be used another thread?

#

Why it freezes unity by blocking main thread, it is async

sage radish
#

It might, sure. But then the main thread is waiting for that thread.

cloud crag
#

Ah. Maybe

sage radish
#

Unity wants those samples now. You can't tell it otherwise. It ought to be asking for it in a separate thread, and I think it might for following calls to the callback, but just creating the AudioClip will invoke your callback on the main thread.

#

So you better have those samples ready to go when you call AudioClip.Create

#

Maybe try logging the audioChunk.Length to see how many samples Unity is asking for initially.

#

Or a breakpoint.

cloud crag
#

Aah, may be. very clever!

#

I will try some stuff and tell how it goes. Thank you very much for advice!

scenic forge
#

Huh, does StartSpeakingTextAsync not have the entire thing ready by the time it's done?

sage radish
cloud crag
#

Yes, it has but auciocllp is not created

#

and creating it takes time as I see on profiler

#

var readBytes = audioDataStream.ReadData(audioChunkBytes); this line

#

and am trying to make this work on different thread and wait or something

sage radish
# cloud crag Yes, it has but auciocllp is not created

The data isn't ready. It wouldn't take this long to copy some samples. The AudioClip creation is taking a long time, but only because it's waiting for your callback, while it's waiting for the download stream to accumulate enough samples to return for this initial callback.

cloud crag
#

Ah, you mean this>

#

FromResult is not ready yet

#

But how can it return unready value since it is synchronous?

sage radish
#

This AudioDataStream is managing its own buffer, so you can just use it instead.

sage radish
# cloud crag So you mean doing this

You can use the audioDataStream.CanReadData method to check if it has downloaded enough bytes. You shouldn't create the AudioClip until it has enough so that it doesn't need to wait when you create it.

cloud crag
#

Ah. Let me check

sage radish
#

How many bytes you need to wait for depends on how much Unity is asking for initially, which is why I recommended logging/debugging to see how big the audioChunk.Length is for the first call.

cloud crag
#

Ok, I will log it

#

I have no idea how to thank you man

#

Let me try

#

There is nothing like that array, only this

sage radish
cloud crag
#

Yes but audioChunk is not created there

#

It is result of callback

sage radish
#

I know, Unity is giving you this array to fill it in. You want to know how big of an array Unity is giving you, so you know how many samples you need to preload before calling AudioClip.Create.

#

This is just a temporary log to see what the number is.

cloud crag
#

what should Iog?

#

what exaclty

sage radish
#

Debug.Log(audioChunk.Length), inside the callback.

cloud crag
#

Ah, I was confused sorry. Ok 1m

#

4096

#

audioDataStream.CanReadData(4096);

#

while it is not true

sage radish
#

Ok, so you need 4096 samples. It looks like you're getting 16-bit audio samples, so that's 4096 * 2 bytes.

cloud crag
#

wait yes?

cloud crag
#

So I have to modify this function to be coroutine and yield return null untill it is not true?

sage radish
cloud crag
#

Ah why is it lowerCase. weird

#

async void?

#

and Task.yield()

#

?

hardy nymph
#

any help?

sage radish
cloud crag
#

I do not think so. it is called in coroutine and coroutines operate on main thread

sage radish
#

Or nevermind, I guess synthesizeSpeech is creating the AudioClip.

cloud crag
#

Ah, I tried it and Unity does not freeze!

#

BUt

#

it does not talk either

#

;d

#

Maybe The problem is found but I miscommented some code or something

#

Let me check

#

sometimes it is not 4096 is it ok?

sage radish
#

Yes. Those four calls might be all part of the initial creation, so you may actually have to wait 4 times longer.

sage radish
cloud crag
#

No no

#

It worked

#

everything

#

You are amazing man!!

#

Thank you very much for your time, I appreciate it

#

Have a beautiful day. I was stuck around 2 days for this

sage radish
cloud crag
#

Naah, it is not

#

Thank you very much!

granite bane
# hardy nymph any help?

You might need to use Type.GetType specifying the assembly name where UnityEngine.Transform is located

dry bear
#

Hi, I am trying to skew a UI panel by modifying the vertex positions with

protected override void OnPopulateMesh(VertexHelper vh)

But this only seems to affect the vertices of the image that the script is on, how could I modify as well the vertices of all the child UI elements?

tawny gull
#

If you could help me, I would be very pleased.

Problem Description:
You have a Unity project with a MyScript component containing a public UnityEvent EHello and a public void Hello() method. You're trying to create an Editor script that opens a custom window allowing you to assign the MyScript component to a GameObject and add its Hello method as a callback to the EHello event. However, despite adding the callback through the Editor script, you're unable to see the callback listed in the UnityEvent's callback list when looking at the GameObject in the Inspector.

Steps Taken:

You created an Editor script named MyWindowEditor.cs that opens a custom window named MyWindow.
Inside MyWindow, you added an ObjectField to select the target GameObject with the MyScript component.
You provided a button in the MyWindow GUI to add the Hello method as a callback to the EHello event of the selected MyScript component.
You utilized EditorUtility.SetDirty(myScript) to mark the object as dirty to ensure the change is serialized.

Remaining Issue:
Despite successfully adding the callback through your Editor script, the callback is not visually listed within the UnityEvent's callback list in the Inspector of the selected GameObject.

tawny gull
tawny gull
#

Is there any source about Unity's scene description code? My goal is to write a scene without using unity editor.

plush hare
#

I'm looking to speak to someone whose written a code generator from scratch in unity.

The problem I'm faced with, is that when I generate code on the backend based on existing user types (using reflection), whenever the user deletes that type, like a struct, the type obviously no longer exists. So errors now occur on the code-generated backend. When there's errors, the assembly obviously doesn't get rebuilt, and therefore I'm stuck with old reflection data telling me that types exist (when they don't).

#

How is this mitigated?

#

Whenever the editor recompiles, I could have it automatically go through and delete all generated code, let it recompile, generate new code, and recompile again, but that's super icky

#

My current solution uses a really limited code analyzer that I wrote that literally parses specific files for structs, etc but it's a massive pain in the ass to use, and I would rather just use reflection.

haughty frigate
#

DOTS related question here (hope its ok to ask in here rather than making a forum post, if not I'll copy it over 🙂 )

Do bakers get executed at runtime against objects that are instantiated?

plush hare
#

it's hidden by default for some reason though

haughty frigate
#

Hm I can't find it in the channel browser. I can see the archived (locked) dots channel?

Unless you mean its hidden behind a Dots roles?

plush hare
#

Try this

#

I couldn't find it at first either. Someone had to link it for me

haughty frigate
#

Oh its a forum, thanks 🙂

tawny gull
dusty wigeon
plush hare
#

gonna be slow as hell but thats alright

dusty wigeon
plush hare
#

Dynamically creating ECS dynamic buffers. The type has to be known at compile time

dusty wigeon
plush hare
#

correct

dusty wigeon
#

I understand, there is no other approach then code generation.

#

Personally, I would just gave up. Pretty sure you can write a few line of boilderplate code. However, I understand your wants.

plush hare
#

Can't give up when you have OCD 🙂

#

it becomes an obsession

scenic forge
scenic forge
#

Yeah that’s basically the downsides of code generation via editor script

#

You have to tab back into editor for them to run, but editor has to first compile other scripts; you have to manually manage generated scripts including deleting no longer necessary ones; and then after generation there’s another compilation step to compile freshly generated code.

#

It’s really bad DX comparing to source generators, where there’s no need to tab back into editor for them to run, and it runs directly in your IDE whenever you change code; it won’t actually generate physical files that pollute source control; managing generated files is automatically done for you so you don’t need to worry about deleting old files.

#

Downside is you have to write your code generation using syntax based API, rather than reflection based.

plush hare
#

Yeah, that's whats off putting to me. The main issue with the editor script generator is really just figuring out how to solve the infinite loop issue

#

and figuring out when new code needs to be generated

scenic forge
#

It gets even worse if you want to edit the editor script that does the code generation, because your project would be in a broken state and wouldn’t recompile to trigger the new generation 😅

#

Tbh this sounds like source generator is the better way to go than editor scripts.

plush hare
#

I'm just wondering how people did this before source generator compatability was introduced to unity

#

afaik it's pretty new?

scenic forge
#

Somewhat new.

#

What files does your editor script generate?

plush hare
#

just cs files

#

I need to generate stuff that can't be done via reflection. Like dynamically creating ECS buffers of different types

#

Could it work if I only generate code when the play button is pressed or before actual build compilation?

#

probably not since that's still gonna leave room for errors when the user modifies the code on his end

scenic forge
#

I meant like, you generate code based on some other code right, so let's say you generate some code based on Foo.cs and Bar.cs, do you put the generated code in Foo.g.cs and Bar.g.cs, or do you put them all in one file like ECSGenerated.g.cs?

plush hare
#

They can each be separate files

#

that's how I'm designing it

#

the generated code also has a generated header and footer, so it knows what it needs to wipe

scenic forge
#

Yeah I would suggest put them all into one file, so dealing with deleting old generated code is easier since you are just repeatedly overwriting that one file.

plush hare
#

Do you have any ideas of dealing with the infinite loop though? I was thinking doing something with comparing the Assembly ModuleVersionId's

#

and storing it in a txt file somewhere after each generation

scenic forge
#

That's a bit too complicated, the easiest way is to make your editor script generated code stable. Eg if code generated based on Foo.cs will never change unless Foo.cs changes.
Prior to source generators, the biggest challenge of making editor script based code generation works, is that every step has to at least compile, in order for editor script to be able to receive the new assembly to generate new code.

Take an example of Foo.cs:

public partial class Foo
{
    [GenerateHelper]
    private float _value;
}

And your code generation wants to generate this based on the above:

partial class Foo
{
    public float Value => _value;
}

The editor script would:

  • Every time assemblies change, scan all assemblies to find usages of GenerateHelper.
  • Generate code, and write them to GeneratedHelper.g.cs.
  • Recompile (if GeneratedHelper.g.cs hasn't changed, Unity won't do anything, so you can freely always write to it as long as your code generation is stable)

The workflow for adding a new Bar.cs/adding new fields to Bar.cs:

  • Add Bar.cs, but only the fields with [GeneratedHelper], and do not write any code that requires using those generated helpers yet.
  • Tab back into editor, it should compile first for Bar.cs.
  • And then it should compile a second time triggered by your editor script code generation, and writes to GeneratedHelper.g.cs.
  • Now you can tab back into your IDE and start writing code that uses those generated helpers.
#

The workflow for editing/removing fields or Bar.cs entirely:

  • Remove fields/Bar.cs that use [GenerateHelper].
  • Go into GeneratedHelper.g.cs and change all of those generated helpers' implementations to throw (so that you don't need to change your existing code that are still using those helpers)
  • Tab back into editor, it should compile first for both Bar.cs and GeneratedHelper.g.cs.
  • And then it should compile a second time triggered by your editor script. This time all the generated helpers are gone and your existing code that still using them will fail to compile.
  • Tab back into IDE, you can now refactor all the code that are still using the non existent generated helpers.
#

As you can see these workflows suck and are super fragile, if you ever get into a situation where "I've changed some code but it wouldn't compile and thus the editor script can't see new assemblies" then you are going to have a fun time to get yourself into a temporary state to compile first, just so your editor script can see the new assemblies to regenerate the correct code.

plush hare
#

alright

scenic forge
#

Yeah, I'd say if you are considering dealing with the above workflows, then just use source generators instead so you don't have to.

plush hare
#

yeah I'll probably be switching over to a proper source generator

scenic forge
#

Editor scripts generating code based on non code assets (eg Translations.json): good.
Editor scripts generating code based on existing code: bad, terrible, painful DX.

Source generators generating code based on existing code: good.
Source generators generating code based on non code assets: works but not worth the effort.

raw locust
#

Hey, I'm trying overlap capsule in job using dots. I'm constantly getting this exception on line containing overlap.

AssertionException: Assertion failure. Value was False
Expected: True

Fragments of code...

[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]

>in Update
          CollisionWorld collisionWorld = SystemAPI.GetSingleton<PhysicsWorldSingleton>().CollisionWorld; //passed to [ReadOnly]
          CollisionFilter collisionFilter = new CollisionFilter()
            {
                BelongsTo = ~0u,
                CollidesWith = ~0u,
                GroupIndex = 0
            };

>in Job : IJobEntity >>> Schedule()
            NativeList<DistanceHit> overlapHitNativeArray = new NativeList<DistanceHit>(Allocator.Temp);
            CollWorld.OverlapCapsule(start, end, radius, ref overlapHitNativeArray, CollisionFilter);

Any help, can't find anything helpfull online

copper plover
#

How unity terrain works? do it uses splat map or UV?

hardy sentinel
copper plover
hardy sentinel
#

even then 🙄

copper plover
#

How triplanar needs uv?

hardy sentinel
#

UVs are a core part of rendering

copper plover
#

or world space texturing

sage radish
#

No, UVs are optional. You can sample textures using anything you want.

copper plover
#

But the UV is generated on shader

sage radish
#

UVs on meshes, that is. Sure, you have to specify a texture coordinate to sample a texture, which you could also call UV.

#

But you don't need textures to render something

sage radish
copper plover
#

if i use WorldSpace X,Z object position as UV does it counts as mesh UV

sage radish
#

But it also uses UVs, generated on the terrain mesh

copper plover
#

Humm

#

Are not splatmaps heavy? big ram usage and all?

sage radish
#

Depends on the resolution and the size of the terrain.

hardy sentinel
#

aren't splat maps just materials that utilize UVs and parameters? 😛

sage radish
#

A splatmap doesn't need to be super high resolution. The tiled textures revealed by it hide the low quality.

hardy sentinel
#

you paint some part with a specific 'brush', then the terrain renderer runs the shader to color that part

sage radish
#

You're painting a mask texture, which the terrain shader samples to figure out which texture to blend in.

copper plover
#

Is it scalable at all for a big open world game?

#

Won`t it need a lot of splatmaps or big splatmaps?

sage radish
#

Since there are only four channels in the map, if you go beyond four different textures in one terrain section, performance can drop significantly, because it needs to draw that section multiple times.

sage radish
hardy sentinel
#

the more materials u use, the more textures you load, so yeah in this way the more ram will be needed

copper plover
#

I see

hardy sentinel
#

for big open world games you'd be better off with some custom chunking solution

#

-- and load/unload resources on runtime on demand, including HQ/low-LOD textures

copper plover
#

is this the only way to have terrains? splatmaps?

#

Is there any other way? is v-rising using splatmaps?

hardy sentinel
#

I think what was mentioned before was very confusing xD this is #archived-code-advanced so no need to simplify or sugar coat

#

you paint with brushes --> brushes are mapped to a material --> the material uses a shader and some parameter presets --> the shader MAY OR MAY NOT process 0-XX textures

#

you can choose to paint with a brush that modifies the mesh without use of any textures if u want -- just plain math

#

or you can reuse the same texture for different materials and only load them once, but process them differently in each shader

hardy sentinel
#

yeah but it's also much more difficult to pull off 😛 which makes it less scaleable unless you have a technical art team

#

for big open world games you should definitely use chunks, but there's nothing stopping you from using a whole Terrain object as a chunk

sage radish
#

Unless you mean using vertex color instead of a splatmap and have a very dense terrain mesh

copper plover
hardy sentinel
#

meaning you can load/unload the whole terrain object including its resources, and render it on demand

hardy sentinel
copper plover
#

but limited to 4 textures if using vertex color, right?

sage radish
#

The same limitation applies to a splatmap, unless you have multiple splatmaps or do some remapping to split each channel into two or more ranges.

copper plover
#

Microsplat has support for 256 textures with a single splatmap

#

"Features Added:

  • Extends the maximum texture count from 32 textures to 256, storing this in a single splat map instead of requiring one splat map for every 4 textures used."
sage radish
#

You can see this is relying on vertex color in some way. Perhaps combining a splatmap with vertex color to multiply the number of permutations.

copper plover
#

But it can have even 256 textures with a single splatmap

#

I think it store the texture index + weight on a single float

sage radish
#

He explains the limitations of his approach in the video above.

#

But this is an early video, so it might be different now.

hardy sentinel
#

so -- what I had in mind before was the 'paint details' part, not 'paint textures' 😅 so yeah oops

copper plover
#

Ty, i`m using dots to create a terrain engine for my game so this is all useful

mellow sail
#

anybody know how to disable the assembly csharp reference?

#

in assembly definition inspector unity

sage radish
mellow sail
sage radish
#

Since there's no way to specify which assemblies those predefined assemblies should reference, "Auto Referenced" is the only way to do it (or disable it)

mellow sail
#

ahh i see

#

okaay thank you

mellow sail
#

Do anybody of you guys know why sometime a scriptable objects loses its reference on play mode? Like when i referenced a vector 2 of a gameobject in hierarchy, when i pressed play mode, it misses the reference

sage radish
#

They can reference them temporarily, but Unity can't serialize it, so as soon as it's reloaded from disk, you'll lose the reference.

wind moss
#

tldr; attatch it to a scene object and then drag the object into the inspector of the gameobject you attatched it to (is that the problem?)

mellow sail
#

so i have a gameobject (Tutorial Manager) that would contain a list of Tutorial Behaviours SO. The SO would contain a vector variable that would reference an object in the hierarchy (as i remembered, I made the object into a prefab and attach it to the SO but still loses its reference) but when in playmode its missing

#

is there a solution?

dusty wigeon
#

Do not use SO for logic handling. (In this particular case)

#

Use a component in the scene

#

You could always use a component in the Scene than reference it through static variable or GameObject.Find

#

SO does not have the concept of a scene. It lives outside of it.

mellow sail
#

so even though i reference a prefab in the SO it still lose it refence? I want to optimize some stuff, so gameobject.find wont be my key

dusty wigeon
dusty wigeon
mellow sail
#

probably yes, ill do it one more time to check it again

cerulean wasp
#

I'm struggling to add a source generator to my unity project

#

I am trying to follow this microsoft tutorial: https://docs.unity3d.com/Manual/roslyn-analyzers.html
I got up to making the test script in my unity project, but my unity project does not acknowledge ExampleSourceGenerated as a thing, nor ExampleSourceGenerator as a namespace.

#

One thing I noticed is: since I'm on mac, my VS does not have a Batch Build menu item

#

And when the tutorial says to add the label "RoslynAnalyzer" and it is case sensitive, Unity automatically makes that label lowercase when I put it in

scenic forge
scenic forge
plush hare
#

So how does something like Roslyn actually work? Is it literally just parsing the raw IL text?

#

or is something happening at the lower compiler level?

scenic forge
#

Roslyn, or just Roslyn analyzer?

plush hare
#

The analyzer

cerulean wasp
scenic forge
#

You can explore syntax tree with https://sharplab.io, change the "results" dropdown to "syntax tree."

plush hare
#

ah alright

cerulean wasp
#

this is what I'm looking at rightnow

scenic forge
#

Your .csproj should be generated at project root, you should have a few like Assembly-CSharp.csproj, ones for editor script assemblies, etc.

cerulean wasp
#

I got access via plain text editor

#

<Analyzer Include="/Applications/Visual Studio.app/Contents/MonoBundle/Addins/MonoDevelop.Unity/Analyzers/Microsoft.Unity.Analyzers.dll" />
<Analyzer Include="/Applications/Unity/Hub/Editor/2022.3.2f1/Unity.app/Contents/Tools/Unity.SourceGenerators/Unity.SourceGenerators.dll" />
<Analyzer Include="/Applications/Unity/Hub/Editor/2022.3.2f1/Unity.app/Contents/Tools/Unity.SourceGenerators/Unity.Properties.SourceGenerator.dll" />

#

I take it all these .dll files are standard, and I just need to add a path to my dll in my source generator project's .dll?

scenic forge
#

No, you need to do it like the Unity manual tells you to, by adding the dll and adding the RoslynAnalyzer label.

#

Editing .csproj doesn't do anything, .csproj is generated purely for DX.

cerulean wasp
#

yikes. well, it is not included

#

and if I add the RoslynAnalyzer label, it makes it automatically lowercase

#

looks like this, at the bottom

scenic forge
#

That's asset bundle, not asset label.

#

Click the blue tag icon.

cerulean wasp
#

that helps

#

ok now it's going. ty

#

I could not find a tutorial to show me

scenic forge
# cerulean wasp

On a side note I don't think you should select any platform at all, since SG is only run during build time.

#

I think the wording in Unity manual is wrong/confusing on that part.

cerulean wasp
#

it works!

#

yeah, I was just following directions as closely as possible because it wasn't working lol

plush hare
scenic forge
#

Whenever compiler runs.

cerulean wasp
#

it finally goes. now time to learn to make it do what it needs to do. ty

scenic forge
#

Compiler runs not only in Unity, but also in your IDE. That's why SG gives you the amazing DX that whenever you changes anything, the source generated code are immediately updated and you get autocomplete/compile errors/etc.

plush hare
#

alright

cerulean wasp
#

I noticed VS doesn't let me find the file for the auto-generated source code. does it not have a file?

scenic forge
#

Generated code are in memory only (and that gives the nice side benefit that it doesn't pollute your version control) but you can view it in VS project explorer IIRC.

cerulean wasp
#

ty

scenic forge
#

You should be able to use typical IDE features like go to definition/find references/etc just fine (though someone else said it wasn't workng for them)

cerulean wasp
#

is it possibly to get a roslyn analyzer for VS on mac?

#

on windows, it's very easy to get .NET CompilerPlatform SDK

wide anvil
#

I have been reading into FSMs, behavior trees, GOAP --- do yall have any tips for making player-like bot roaming?

#

Like just looking around for other players to hunt down

dry bear
#

hey guys, I am trying to add skew support for the UI, and I made a script to apply the same skewing matrix to all the children of a UI element, but it doesn't look right, should I be calculating a matrix for each UI element separatelly?

#

not too sure how the maths for that would be

modest vale
#

Changing my terrain rendering to unity dots

plush hare
#

https://docs.unity3d.com/Manual/roslyn-analyzers.html

What do they mean in the second part by "Unity doesn’t support the installation of Roslyn Analyzers or source generators through NuGet directly".
We're compiling the source generator into a DLL outside of unity, so why would I need to install anything inside unity?

#

I'm so confused.

upbeat path
#

but your dll will not contain the dll's that it references, so when you put your dll into a unity project it will need access to those referenced dll's as well

dusty wigeon
wide anvil
#

Just worse haha

#

Like how fortnite supplements lower level lobbies with bots so new players still have a decent chance of winning

#

My game is a top down large scale 2d multiplayer game. The movement and killing scheme is similar to among us

#

Im currently leaning towards trying to trying to train my bots with unity ml agents but I don't have a good sense of if i'm in over my head.

#

I know ML agents is fairly unsupervised but I see they also have imitation learning -- looking into that rn

plush hare
#

So my source generator is spitting out files in the temp folder on my hard drive. Is there any way to get them to generate inside of the project?

scenic forge
#

Why though? Them not generating actual physical files is one of the nice benefits since they won’t pollute your source control.

plush hare
#

That's true. I guess I just want to be able to read the output to verify everything. It's not that big of a deal.
I am however getting a warning when accessing the generated class. It's "conflicting with the imported type"

#

Other than that, it seems to be working

plush hare
hoary merlin
#
        public static T CopyComponent<T>(GameObject source, GameObject destination, bool force = false) where T : Component
        {
            if (force)
            {
                Component comp = destination.GetComponent<T>();
                if (comp != null)
                    GameObject.DestroyImmediate(comp);
            }
            T sourceComponent = source.GetComponent<T>();
            if (sourceComponent == null)
                return null;
            T destinationComponent = destination.AddComponent<T>();
            System.Reflection.FieldInfo[] fields = typeof(T).GetFields();
            foreach (System.Reflection.FieldInfo field in fields)
            {
                field.SetValue(destinationComponent, field.GetValue(sourceComponent));
            }
            return destinationComponent;
        }

Does anyone have any idea why typeof(T).GetFields() is empty? I can't seem to find anything.

scenic forge
plush hare
#

I have Assembly-CSharp and Assembly-CSharp.player

#

in the unity project.

scenic forge
#

Probably your SG unconditionally generates an example class for both assemblies.

chilly nymph
#

Is there a better way to cache sprites?
I will have anywhere from 20-1000 sprites I need to pull from my resource folder, and in the future from a game updates API https Request that will store "image" to their device; and keep in memory because of this and the uncertainty of keeping 1,000 sprites in a collection I wanted to know if there's a better way than storing the Sprite in a dictionary that I'm currently doing. (Hoping there's something that already exists that I missed), Addressable won't work as I have my own modding system that handles custom data added into the game.

Each sprite is 128x128.

Dictionary<string, Sprite> spriteMap = new();
   
 public async Task<Sprite> LoadSpriteAsync(string spriteFile)
    {
        if (spriteMap.ContainsKey(spriteFile))
        {
            return spriteMap[spriteFile];
        }

        var spritePath = Path.Combine("sprites", spriteFile);
        var resourceRequest = Resources.LoadAsync<Sprite>(spritePath);

        while (!resourceRequest.isDone)
        {
            await Task.Yield();
        }

        if (resourceRequest.asset != null && resourceRequest.asset is Sprite loadedSprite)
        {
            spriteMap.Add(spriteFile, loadedSprite);
            return loadedSprite;
        }
        else
        {
           //Do error 
            return null;
        }
    }```
untold moth
chilly nymph
untold moth
chilly nymph
#

Basically looking if there's any sprite handler in unity that would just hold a reference or some other pointer.

chilly nymph
untold moth
#

Pointers point to somewhere in memory. The sprite would need to be loaded in memory to have a pointer to it.

chilly nymph
untold moth
#

Better in what way? Do you want these sprites to be cached? Then they will need to be in memory.

chilly nymph
untold moth
#

Alternatively, you can not cache them and load them every time you access them.

untold moth
chilly nymph
#

I may just drop the sprites and handle the raw data.

#

I just don't know the overhead for that without testing.

#

Write a webp encoder / decoder.

long ivy
#

you took a hard turn for some weird wtfery there

untold moth
chilly nymph
#

The issue is I can potentially have 1,000 images in the game being pooled and used at some point.

untold moth
#

Are you actually running out of memory on your target device or is it a premature optimization?

chilly nymph
#

So yes, I can just I/O the textures when I need them, but that seems like a waste.

My only real option I see is just create a collection of First in textures, then releaase any that haven't been pulled in a while.

chilly nymph
untold moth
#

Why not just load the textures that you really need and unload them when they are not needed. Instead of messing with raw bytes?

Premature optimization is when you try to solve a problem that doesn't exist yet.

chilly nymph
untold moth
#

By loading the files as raw bytes, you probably won't be saving any more than 1% of the memory depending on the image resolution and format.
Besides, I'm not sure you would be able to pass that data into a Texture2D properly afterwards.

chilly nymph
#

When a user loades the game, it hits our update server, websockets the raw images, stores to device and loads when needed.

chilly nymph
#

Dealing with them is trivial.

long ivy
#

it makes absolutely no sense to do anything at all with raw bytes. You don't load those into memory, you leave them on disk where they take 0 memory space until you use them. Then when it's needed, you load into memory in a usable format

chilly nymph
long ivy
#

if you're downloading them into memory and not saving them then that is where your actual problem lies

untold moth
#

If you only need to download them, then for sure, just download the raw bytes and save them to disk.😅

chilly nymph
long ivy
#

otherwise you're talking a worst case scenario of 1000 128x128 RGBA uncompressed textures taking a whopping ... 60ish mb of vram

chilly nymph
#

You guys are so far off the actual original question trying to discuss something that has nothing to do with what I orignially asked.

jolly token
untold moth
#

Basically, unload them if they're not needed. That was suggested several times already.

chilly nymph
chilly nymph
jolly token
scenic forge
#

You should investigate the access pattern of those sprites

#

Without knowing your access pattern, any optimization is moot.

chilly nymph
#

Any PO that takes a day or two then you should rethink, not something that takes a hour or two.

scenic forge
#

Throwing things at the wall and seeing what sticks doesn't really do well 😅

chilly nymph
#

A waste of time?

long ivy
#

if it solves a non existent problem, yep that would be my definition of a time waster

chilly nymph
#

I'd rather do it once than have to refactor later.

chilly nymph
scenic forge
#

If you investigate your access pattern first, you may gain insights such as "95% of the sprites are no longer used/only used again after 5 minutes of gameplay" then you can properly turn that into an optimization strategy of "purging cached sprites if it hasn't been used for more than 5 minutes"

#

That's way more useful than whatever 10% you can save by storing the raw bytes.

chilly nymph
#

Way more of an investment than just doing it the way I think is the proper way.

tall ferry
#

then just do it your way if you consider that proper..

chilly nymph
#

I hear what you're saying, and agree mostly, but implementing a sprite cach / unloader is worth it.

scenic forge
#

You don't need to deploy a server and collect analytics from all your players, what you should be doing is simply not worrying about it and keep developing your game.
Once it's near a realistic playable version, then you can do a test play on your dev machine, following a typical play pattern of your players, and just debug log whatever to gain insights.
Then afterwards, you do the optimizations.

chilly nymph
#

Basically I was hoping that there was some archaic functionality one of you would have known about that handles this solution as it's one that I'm sure a lot of people have dealt with.

chilly nymph
#

You telling me how to develop like I don't know what I'm doing doesn't do anything.

scenic forge
#

Sure, I've offered my suggestion of profile first before optimizing, I have no more to say.

chilly nymph
#

I hear what you're saying, but in this case I disagree, as doing this properly I've already decided needs to be done.

chilly nymph
scenic forge
#

I'm not saying you shouldn't optimize or that this is premature optimization, I'm saying your optimization strategy should be obtained by empirical data and specifically how those sprites are accessed in a realistic gameplay of a player.

untold moth
chilly nymph
#

So you're trying to suggest and fix a problem that isn't a problem. Youre trying to suggest that I don't know how to handle my time as a developer.

scenic forge
#

Okay, so you've spent 1-2 hours implementing the "storing raw bytes in memory rather than decompressed texture" and now you saved 10% memory consumption, great.
But you still could've saved way more than 10%, if you knew "95% of the sprites won't be accessed again after 5 minutes of inactivity" and use a strategy of purging sprites that are stale by more than 5 minutes.

#

Some day when your memory consumption is once again going over the board and you have to do profiling to gain that insight to really fix your problem, that 10% memory consumption optimization you spent 1-2 hour making is just wasted time.

austere jewel
#

What's the actual question?

#

Because it kinda just sounds like a poorly explained problem and then a whole bunch of arguing about other people's opinions about the poorly explained problem

scenic forge
#

This is akin to "optimizing locations of your data centers when your database queries have a N+1 problem"

chilly nymph
# austere jewel Because it kinda just sounds like a poorly explained problem and then a whole bu...

A bunch of juniors trying to argue what Premature Optimizing is, done with what I assumed was my only option was here anyways. Was hoping there would have been a unity function for this that I missed.

   private Stack<string> spriteStack = new Stack<string>();
    public async Task<Sprite> LoadSpriteAsync(string spriteFile)
    {
        if (spriteMap.ContainsKey(spriteFile))
        {
            return spriteMap[spriteFile];
        }

        var spritePath = Path.Combine("sprites", "cards", spriteFile);
        var resourceRequest = Resources.LoadAsync<Sprite>(spritePath);

        while (!resourceRequest.isDone)
        {
            await Task.Yield();
        }

        if (resourceRequest.asset != null && resourceRequest.asset is Sprite loadedSprite)
        {
            if (spriteMap.Count >= 300)
            {
                string leastUsedKey = spriteStack.Pop();
                spriteMap.Remove(leastUsedKey);
            }

            spriteMap.Add(spriteFile, loadedSprite);
            spriteStack.Push(spriteFile);
            return loadedSprite;
        }
        else
        {
            var errorMessage = "Could not load sprite: " + spritePath;
            var notifiationData = new NotificationData("Error", errorMessage, NotificationType.Critical);
            notificationController.Set(notifiationData);
            return null;
        }
    }

austere jewel
#

These people are not juniors

chilly nymph
plush hare
#

What's your problem dude? Chill out

austere jewel
#

You've come in here with some preconcieved notion about what the solution to your problem is, poorly explained what you wanted to achieve, and got angry when people are trying to tease out the real problem and what your actual question is

stable python
#

I'm working on a loot table and just learned about Parallel processing. Would implementing Parallel processing for loot tables be advantageous, or would a simple loot table work if the player is collecting loot from 50 different sources at the same time.

    public void Loot(string location, string tier)
    {
        string key = $"{tier}_{location}";

        if (lootItems.ContainsKey(key))
        {
            int totalChances = lootItems[location].Sum(item => item.chance);
            int lootRoll = Random.Range(1, totalChances+1);
            foreach (var lootItem in lootItems[key])
            {
                if (lootRoll <= lootItem.chance)
                {
                    itemStorage.LootItem(lootItem.itemName, 1);
                    break;
                }
            }
        }
    }```
austere jewel
#

don't be obnoxious, and just assume people are actually trying to help

chilly nymph
#

poorly explained question

chilly nymph
austere jewel
#

It's poorly explained because you're asking about caching something because of memory concerns, and yet got up in arms when told caching involves having things in memory. Was your actual question how to store them on disk?

#

What actual function are you looking for? What is does caching mean in this scenario? What are you actually trying to do? Storing something in a dictionary or something else, it's all meaningless

chilly nymph
plush hare
#

lmao

stable python
chilly nymph
jolly token
stable python
plush hare
untold moth
austere jewel
jolly token
stable python
stable python
scenic forge
#

If you are coming from a Flash background (hasn't that thing died for close to two decades now) then you might be surprised at how fast compiled languages like C# are.

untold moth
plush hare
#

Unless it's actually a problem to begin with, you're going to make so much work for yourself trying to multithread it. Especially if you already have slow code to begin with.

scenic forge
#

Unless the code you are writing is some deep foundational building block of your architecture, delay profiling and optimizing it to as late as possible.

stable python
plush hare
#

If you don't know what you're doing, your multithreaded code will end up being slower than single threaded anyways.

scenic forge
#

I've seen countless times people having an unfinished game, so one part of the code is seemingly more important than it actually is in the finished game where optimizing it wouldn't make a real difference.

plush hare
#

Unless I'm misunderstanding how loot tables work, 50 / second is literally nothing anyways

#

even on mobile hardware

stable python
#

Ok. I guess I'm worrying over nothing. I'll just write it as i have it and stress test it and see if it is a problem. Thank you. This helps a lot.

plush hare
#

that's one thing I didn't understand early on, and it killed the performance of my applications

stable python
#

Ok I will learn what a struct is and Profiling.

austere jewel
#

Imo structs are not a fixer, and misusing them can cause way more problems than just using a class ever would

scenic forge
austere jewel
#

Boxing...

jolly token
#

Unity Rust support pls 😄

scenic forge
#

Yeah boxing too, especially if you start implementing interfaces and boxing can sneak in without you noticing.

stable python
#

If ive learned one thing to day is that I know nothing about coding. the hell is Boxing.

#

you dont have to answer that Ill ask Chat GPT

austere jewel
#

Structs need to be wrapped up in an object in certain cases and put on the heap, and that allocates. You can easily do it mistakenly by passing structs through methods that aren't using generics but are using interfaces.

austere jewel
plush hare
#

yeah chatgpt is god awful for programming related things

#

it was banned from stackoverflow for just making shit up

stable python
#

._. I'm using it to teach me how to code for like the last 4 months

untold moth
#

It can be fine if you know what you're doing/how to work with it.
It's just that this community is a bit biased against it, so better not mention it here. 😛

stable python
austere jewel
#

Already completely wrong in the first sentence

half swan
stable python
#

I didn't want to start problems sorry. I do use it and If it can't help me than I come here to learn. But I dont wanna have to stop and ask real people for help everytime a run into an issue. cause thats atleast 3 times a day.

tall ferry
austere jewel
untold moth
#

Perhaps gpt-3.5 is less reliable in this case. I rarely use it for coding question. GPT-4 would be right most of the time.

austere jewel
#

🇽 to doubt

plush hare
#

and then when you break something and you tell your boss "chatgpt did it". He's going to fire you

untold moth
#

I mean I'm using it at my work to solve all kinds of problems in different languages and frameworks and it boosts my productivity by quite a lot. There are instances when it is not helpful of course, but these are cases where I myself have to google for a good 30 min to figure it out.
But I guess there's not much point in convincing anyone here.🤷‍♂️

#

That being said, I would definitely suggest double checking the information that it provides you, especially if you don't have some background knowledge on the topic.

scenic forge
#

The generative power of it is pretty good, especially for things like writing tests or mundane. If you already know what you are doing and just too lazy to do it, letting it generate and you review it is pretty nice.

#

I'm mostly against it for beginners trying to learn.

austere jewel
#

It's quite convenient to plagarise the works of others through a large statistical model 😛

scenic forge
#

It's not a reliable source of information, and the last thing you want while learning is not knowing if you are even learning the right thing.

untold moth
austere jewel
#

No, if I'm copying code from somewhere, especially from somewhere with a license, I will include that license in the code, or at least have a comment pointing to where I found it

jolly token
#

I think Bing AI does it

untold moth
austere jewel
#

If I'm making new code from knowledge gained from learning, then I have learnt something myself and applied it

#

I also am aware of where it came from, and recommend those sources to people when I talk about it

untold moth
#

Well, the model also learned from the training data to generalize to different problems. You don't usually include licenses on everything you've seen with your eyes.

#

As long as the learning/training material is gained legally, I don't see a problem.

austere jewel
#

The model hasn't learned anything

#

nor is it ever crediting anything

tall ferry
#

This reminds me of the classic: A: "I stole your code", B: "Its not my code"

austere jewel
#

"I made this"

austere jewel
untold moth
austere jewel
#

If it was learning it would have knowledge instead of just the ability to generate convincing looking text

#

There is nothing following on from this where the AI has sentience

untold moth
#

It does though. And generating convincing looking text is not as easy as it might seem.
And you don't need sentience to learn something. It's simply a mechanism of approximating a function that gives a good solution.

dusty wigeon
#

@untold moth, If AI is empowering you and you have no moral issue in using it, feel free to use. However, AI is most of the time factually incorrect and induce a LOT of people in error thus making it poorly suitable for answering question.

austere jewel
#

Even Unity's Muse being definitely sourced using their own documentation is a moral problem, as I doubt the technical writers who wrote it actually agreed to it. Which is another scenario of "it's probably not right, but we can't do anything about it", workers having their work transformed infinitely out of the original context they wrote it for, without seeing any profit from that transformation.

chilly nymph
austere jewel
#

Which is a major reason why there's a massive writers strike going on

dusty wigeon
chilly nymph
dusty wigeon
#

Even source needs to be double verified.

dusty wigeon
#

That would be pure malice.

chilly nymph
austere jewel
#

Do what you want, I will continue to view it as morally reprehensible though 🤷

dusty wigeon
#

And still relying on it.

chilly nymph
plush hare
#

Philosophical conversations in the advanced programming section are always great

chilly nymph
#

I personally think AI is a great tool, but you need to understand the source material to use it properly.

Copy pasting AI outputs is like copy pasting Stack overflow.

untold moth
dusty wigeon
chilly nymph
austere jewel
#

It doesn't act with any thought, knowledge, idea, etc. It has no malice, but it certainly exists and performs maliciously

#

These are not mistakes, these are pure fabrications for no reason but the statistics that made the model perform its function in the first place

dusty wigeon
chilly nymph
#

an action or judgment that is misguided or wrong. In terms of AI you can apply a mistake, this is the entire argument of "What is good".

AI can In my opnion (and yes I understand your guys point) make mistakes, from what they are intented to do.

#

AI doesn't fabricate as it's just outputs what it wants.

untold moth
# austere jewel These are not mistakes, these are pure fabrications for no reason but the statis...

What if you give a person incomplete learning material. Let him read it and make certain conclusions.
Then when you ask them a certain question on the topic of the learning materials, they get it confidently wrong. They simply made wrong conclusions, but they are confident in their answer because they think they learned it from the training data. Wouldn't that be the same as the model giving a wrong answer?

chilly nymph
#

It's your role as a user to understsand this and apply it while using AI

#

If a dog doesn't do what you want it's not imorral. You are the master.

austere jewel
chilly nymph
#

^ It's literally What data comes next

untold moth
# austere jewel No. The model doesn't have knowledge on a topic, you can get it to generate conf...

I'd disagree with that.
There's an interesting research paper called "TinyStories: How Small Can Language Models Be and Still Speak Coherent English?"
Reading that kinda changed my perspective on the LLMs.
To put it simply, it's not possible to generate a coherent text without certain understanding of it. Not just syntactically or grammatically, but semantically. The model does have a certain understanding. Words and other building blocks of language are basically concepts that can be represented in numbers(in the case of LLMs - multidimensional vectors) and there are relationships between different concepts. The model learns these relationships and knows what words to output next based on the whole context. It is next token prediction, but next token prediction requires so much more than just some statistical model.

austere jewel
#

Things are semantically connected in the model, but these connections and relationships are not understood by the model. You can for example make an approximate semantic comparison between different sentences by compressing the inputs as pairs and comparing the resulting lengths. A relationship exists between A and B when the compression distance is small, these two things are likely related. It doesn't say shit about knowledge or understanding though, the model can just group things somewhat successfully. In the case of LLMs the grouping of related constructs in a sentence is very well understood, it can generate human-looking language. In the case of things outside of language, it falls apart and these relationships are just endlessly pushed around by each new model, having confidence boosted in some areas, and totally lost in others. You lose knowledge because the model's "understanding" of related things is not based on knowledge, it's not based on "learning". Learning as a term in these AIs just means progressing closer to the desired outcome over time, it doesn't actually mean anything meaningful was considered along the way to get there

#

But all of that is irrelevant imo, none of that compares to the immorality of scraping the work of others for the sake of a text generator that can gain you revenue off the backs of workers. That just speaks to why the model's will never be able to be relied on for correct answers.

dusty wigeon
#

@untold moth @austere jewel, the nature of the AI means little anyway. It could be the most "intelligent" being ever, if it gives factually wrong answer or hallucinate things its value is greatly diminished to the point where it is barely usable.

austere jewel
#

I also don't understand how people don't realise how insulting it is to have people you spend time explaining something to, writing resources for, only to have them go "thanks! I will go ask this text generator now"

chilly nymph
dusty wigeon
chilly nymph
#

Google can give a wrong answer, doesn't mean it's flawed or it's unusable.

austere jewel
#

If documentation gives you a wrong answer you report a problem or make a PR and it gets fixed

#

by people

chilly nymph
half swan
#

Personally, I've just never had any positive experience with it, including gpt4

I have to double check its work and often come up with a completely different solution. It's generally way faster to just look at the docs, even if they just show the method names and properties, it's still often more helpful to me

austere jewel
chilly nymph
chilly nymph
untold moth
# austere jewel I also don't understand how people don't realise how insulting it is to have peo...

I see how it can be disappointing. Might be arrogant coming from me, who never wrote or published something for the sake of other people, but I think if it was my creation that was used as a training data, I wouldn't consider it offensive. If that would help transfer my knowledge to someone else, even indirectly, that's fine with me. After all "my" knowledge, wasn't "mine" in the first place. I didn't invent any of it. And even if I did, it was just putting together some concepts that existed before.

half swan
austere jewel
#

Whether or not you would be find with it really doesn't matter

untold moth
austere jewel
#

We can disagree 🤷

dusty wigeon
#

I also feel like it is a matter of opinion HOWEVER it has systematic issue for sure that cannot be dismiss.

chilly nymph
#

Almost every large company uses spiders for data, it's not any different than what AI uses.

vast shale
#

I've never wanted to GTP to write code for me, seems totally unnecessary and not something I'd really trust workflow wise. As an extension tool to Unity's docs though, it's amazing. Often I need a bit of information that I know is in the docs, but maybe I'm blanking on exact terms or references. GPT's ability to interpret my question in correct detail and give me the exact snippet (that I can then look into further in the docs) is awesome.

scenic forge
austere jewel
#

I am a big believer that cool/convenient doesn't mean something needs to exist; but that also seems controversial against the face of today

chilly nymph
#

I didn't click a link to get that.

vast shale
#

That's coming from extensive Unity experience though, I feel differently about it (and use it differnetly) for other languages - for example I don't really want to become an expert at Google Sheets formulas. It's kinda fun, but just not what I'm ever gonna spend my time on. Having GTP's ability to turn a broad intention into a correct formula I can just copypasta into a cell has been brilliant as well.

austere jewel
#

Or this data?

scenic forge
vast shale
untold moth
austere jewel
#

I will just move into the woods

chilly nymph
untold moth
chilly nymph
#

My only point is the same practices that AI is doing companies have been doing for the last 15 years and no one complained.

austere jewel
#

No-one complained?? Where have you been!

chilly nymph
drifting plinth
#

I am attempting to make a multiplayer lobby system with Photon's PUN 2 and what ever I do when I get the player count it throws me the error: NullReferenceException: Object reference not set to an instance of an object
LobbyManager.Update () The code is here: https://pastebin.com/GBG2Xnh6 Video here: https://youtu.be/-kl-b7NRMRw Ping me

chilly nymph
#

The people that made these reviews are not getting credited. Same system as AI spitting out info.

chilly nymph
austere jewel
scenic forge
# scenic forge The difference is that when you Google something you go straight to the source; ...

This is not just a matter of "AI doesn't cite its sources" but also a point of credibility and taking responsibility. When I answer questions here I'm putting myself out here and if I keep spewing wrong answers or misleading people, there are consequences whether it's in the form of people stop taking me seriously or even worse moderation actions. And what comes along with it is that I can personally improve every time I'm wrong and don't make the same mistakes again.
When AI is wrong...

austere jewel
#

Should probably move this AI discussion to a thread in #497872469911404564, or if you're like me we can go our separate ways (I'm gonna go finish the Witcher 3)

drifting plinth
chilly nymph
scenic forge
#

That message isn't about citing sources.

chilly nymph
#

Custom instructions

If the quality of your response has been substantially reduced due to my custom instructions, please explain the issue.

Do not be playful or tell me how to speak to you, you are a machine, only respond to me like a machine.```
scenic forge
#

It's about AI can't possibly take responsibility.

austere jewel
plush hare
#

Whenever I want to change my source generator, do I really need to delete the old DLL, and upload the new DLL? So damn slow and such a pain

scenic forge
#

Yep it's unfortunate

#

In regular C# projects you can just project reference the source generator project, and you don't need to build anything at all; changes to SG is immediately available in the consumer project.

#

But in Unity, you have to rebuild the SG dll and move it to Unity project's assets.

#

It's helpful that you use dotnet CLI to build the SG project so you can chain a terminal command to copy the dll over, and you just rerun the last command in your terminal.

drifting plinth
scenic forge
#

Silver lining is that SGs don't tend to change a lot once you are done developing them, so it will only be a bit of temporary pain at the start.

drifting plinth
#

Thanks

cerulean wasp
#

Is there a way to make a source generator only run when I press a button or something, and not every time I press a key?

wooden cedar
#

I imagine that would depend on the source generator and whatever is generating it

nova summit
#

Can someone explain how this works?
Wondering what exactly is being done in calculateGlobalRotation and how the rotation is calculated.

To give some context - I have 3d joint positions of joints for RightUpLeg, RightLegKnee, RightLegAnkle. The below code is calculating the rotation required at RightUpLeg trasnform.

        var rotLeftForward = Quaternion.LookRotation(Vector3.left, Vector3.forward);
        //Rotations[1] = calculateGlobalRotation(Positions[1] - Positions[2], Positions[0] - Positions[1], rotLeftForward);
        Rotations[RightUpLeg] = calculateGlobalRotation(Positions[RightLegKnee] - Positions[RightUpLeg], Positions[RightLegAnkle] - Positions[RightLegKnee], rotLeftForward); 

        Quaternion calculateGlobalRotation(Vector3 boneDirection, Vector3 left, Quaternion init)
        {
            var d = boneDirection;
            var up = Vector3.Cross(d, left);
            d.Normalize();
            up.Normalize();
            var target = Quaternion.LookRotation(d, up);
            var rot = target * Quaternion.Inverse(init);
            return rot;
        }

scenic forge
cerulean wasp
#

all I need is something more like InputActions, where I just need to tell it "Yeah, please generate now"

scenic forge
#

Are you having performance issue or?

#

Because my project has 80k LoC in one giant assembly, it has two SGs scanning for attributes and generating code, and I’m getting zero lag in IDE while typing, on a 10 year old laptop that has less RAM than phones nowadays. You’d be surprised how performant SG is, unless you are doing something unconventional.

dusty wigeon
# nova summit Can someone explain how this works? Wondering what exactly is being done in calc...
        //Convert Local Direction to World Rotation (If I am correct, this is from local space to world space)
        Quaternion calculateGlobalRotation(Vector3 boneDirection, Vector3 left, Quaternion init)
        {
            //Current Direction
            var d = boneDirection;
            //Find the up
            var up = Vector3.Cross(d, left);
            //Normalize direction. (Might be unnecessary, I believe that Quaternion.LookRotation already do that)
            d.Normalize();
            up.Normalize();
            //Find the targeted orientation in quaternion.
            var target = Quaternion.LookRotation(d, up);
            //Apply the rotation from the original oritentation. (Convert from local space to world space)
            var rot = target * Quaternion.Inverse(init);
            return rot;
        }

https://gist.github.com/HelloKitty/91b7af87aac6796c3da9

scenic forge
nova summit
#

@dusty wigeon
Actually I wanted to know why/how left value is passed to calculateGlobalRotation. Can't exactly find out why Bone 2 (1-0 joints) is picked as left and passed to calculateGlobalRotation.
And also, consider when Bone 2 (1-0 joints) is bent at some angle (let's say knee bent at right angle ) , the cross product will be something like vector.right which don't give any kind of clue 😐

nova summit
#

I have 3d positions of joints. I need to target a humanoid where it matches those joint positions.

dusty wigeon
nova summit
#

I have positions for all 13 joints so I don't want to do it via IK.

dusty wigeon
#

You are doing a fullbody IK ?

nova summit
#

Yes.

#

I think so. It will end up full body IK.

#

Any pointers on how to solve it. I heard full body IK will be too costly. so wondering if there is any other way.

dusty wigeon
# nova summit Yes.

Then, I'm sorry, but I can't help you there. This is a pretty ambitious challenge. You should just use an asset such as Final IK.

dusty wigeon
nova summit
#

Oh ok. Any directions/theory on how I can move forward?

dusty wigeon
#

Such as 2 bone IK.

#

Then ramp up.

nova summit
dusty wigeon
#

Also, you want to read books and white paper.

dusty wigeon
nova summit
#

Ok, will keep trying! thanks for giving a note on my focus :), yea finally I want to finish my current game 😄
So, I will try for some time and later start with something as simple as 2 bone ik in free time.

hexed meteor
#

Anyone have a minute to help a bad programmer out?

A fail to understand for the life of me why this array, when I clearly can log its length, it's not null... but then in the next line it returns a null reference exception.

fresh salmon
#

The first element of the array is null

#

Not the array itself

hexed meteor
#

How can that be when it has a default value specified in the Contents class

fresh salmon
#

contents[0] returned null

hexed meteor
#

shouldn't it automatically set that value when its created?

fresh salmon
#

When you initialize an array with a specific length, it fills all the slots with the default value of the type the array contains.
If that type is a class, then it's filled with nulls

hexed meteor
#

oh I see... so in this case my values are null after the newWave is instantiated? the assingments I specified are basically ignored?

fresh salmon
#

You don't add anything into your array right now

upbeat path
#

you did not do any assignments to the contents array

fresh salmon
#

From what I can see

#

At some point, you need to do
.contents[0] = new Contents()

#

To fill the first slot

upbeat path
#

you created an empty array each element of which may contain a Content or a null

hexed meteor
#

but when I do 'newWave.contents[i].count = X' it also gives me a null reference, as if the array element index0 didn't exist (but length returns 1 so it must?)

#

oh I see

fresh salmon
#

The array has a length, but it doesn't mean what's inside has valid values

sly grove
fresh salmon
#
new Contents[3];
// -> [ null, null, null ]
hexed meteor
#

oh thanks so much guys!

#

big brained programmer chads hanging out here helping noobies out, really appreciate it

#

this did the job

sly grove
#

One thing Unity does to confuse people about this is that if you did:

public MyClass[] = new MyClass[5];``` it will actually create those objects for you if MyClass is serializable. This is a quirk of Unity's serialization mechanism not how C# actually works under normal circumstances
upbeat path
hexed meteor
#

that is good to be aware of!

wary blaze
#

Does anyone know if there are benefits to using SceneManager.UnloadSceneAsync on a scene with several root game objects, vs calling GameObject.Destroy for each root and then unloading the empty scene?

In my testing, the latter seems better because UnloadSceneAsync destroys all roots in a single frame, whereas with the manual method you can place the Destroy operations in separate frames to avoid single frame FPS spikes.

It seems to me UnloadSceneAsync is just a convenience method to make us have to implement less code, however I want to be sure that there aren't other benefits to using it over GameObject.Destroy.

dawn kettle
#

If any of you are willing to help me with an inventory system dealing with scriptable objects please DM me. I really need some help on this.

steel snow
#

Seem to have an error with my mesh but can't figure out why. I am copying a prefab's mesh to a new mesh so im directly copying the triangles across like this:

            Debug.Log("Total submeshes: " + _prefab.subMeshCount);
            for (int i = 0; i < _prefab.subMeshCount; i++)
            {
                Debug.Log("Submesh index: " + i);
                _mesh.SetTriangles(_prefab.GetTriangles(i), i);
            }

And i get this error:

Failed getting triangles. Submesh index is out of bounds.

What might be the issue here?

#

how can i be out of bounds if i have 2 submeshes yet index 1 triggers the error

sly grove
#

two different meshes no?

steel snow
#

yes im trying to copy the entire thing to another

#

my prefab has two submeshes

sly grove
steel snow
#

well its an editor tool so i didnt want to generate new objects as i want to save the data to a scriptable object

sly grove
#

either way you're going to save the new mesh in the asset right?

steel snow
#

instantiate creates a gameobject in the scene no ?

sly grove
#

no

#

Only if you Instantiate a GameObject or component attached to a GameObject

steel snow
#

oh

sly grove
#

if you Instantiate a Mesh it only creates a Mesh

steel snow
#

so instantiate is like a deep copy?

sly grove
#

yes

steel snow
#

interesting

#

ill try it

#

would i have to add destroy here to avoid memory leaks:

        _prefab = EditorGUILayout.ObjectField(_prefab, typeof(Mesh), false) as Mesh;
        Destroy(_mesh);
        _mesh = Instantiate(_prefab);
#

encase i change the prefab

sly grove
#

yes, but that was the case when you do new Mesh also

steel snow
#

ah lol

#

hm still has the same error

sly grove
#

well wouldn't you be able to delete all of this code now?>

#

Instantiate should do all of the submesh copying etc automatically

steel snow
#

oh true but see im back to my previous issue of memory leak warnings

#

since im not using shared mesh

#

oh i see the issue

#

OnInspectorGUI is every frame so im just destroying and instantiating every frame 🤔

#

need to rethink that

steel snow
#

oh nice

dusty wigeon
wary blaze
dusty wigeon
radiant panther
#

Anyone here good at netcode for gameobjects? I just started and I cant seem to figure out a way to make vehicles like a ship work well. Running into problems where the players movement isnt properly synced as a child of the vehicle. Not really sure how to approach this

radiant panther
#

Ah ty

wary blaze
#

wow

dusty wigeon
#

Our scene range from 100'000 to 200'000 in one project

#

An other has over 1'000'000 gameobject

#

But it was made with tooling an a lot of empty gameobject.

#

Also, knows that Complience Testing Team are strict on loading that stuck because it is a TRC for multiple platform.

#

So, I'm pretty confident that it does not lag out of proportion.

wary blaze
# dusty wigeon Yes

In that case maybe LoadSceneAsync does modulate how many game objects are destroyed in a single frame once the frame surpasses a certain ms threshold

#

and my test doesn't catch that because the unload was literally the only thing happening in the frame

dusty wigeon
wary blaze
#

not unless there's something about LODGroups that has a heavy OnDestroy penalty

#

the game objects only have colliders and mesh renderers (and the LOD Group component on the parents)

dusty wigeon
wary blaze
#

I profiled, but going to try a deep profile.

#

Profiled in a build too. I'll try some more test with more game objects in the scene.

#

It sounds like your game used non additive loading (where the old scene is unloaded automatically). Is that right? Maybe the performance is different than using UnloadSceneAsync, since the latter would theoretically have more work to do in terms of combing the scene for dependencies?

dusty wigeon
wary blaze
#

I guess I'll test that too. Thanks!

copper plover
#

Do anyone here uses poisson disk sampling? any idea how to use multi sized objects?

#

like this

steel snow
#

having a weird issue generating meshes my mesh generates all the verts in the correct place, yet it only renders a 10th of my mesh then its all invisible, ive checked reversed normals its not that either

#

got no idea how to debug the problem

dusty wigeon
steel snow
#

i think i know the problem but not sure of the solution

dusty wigeon
steel snow
#

im copying and lofting a mesh along a bezier spline

#

but im not sure how to update the tri index array correctly

vestal lotus
#
public class Test
{
    public Test()
    {
        Debug.Log("Hello, World");
    }
    ~Test()
    {
        Debug.Log("Goodbye, World");
    }
}```
#

just curious but does anyone know why both the constructor and destructor are called twice in edit mode

untold moth
vestal lotus
untold moth
#

I can't think of a way to create an instance of it without using the new keyword.🤔

frozen imp
#

likely two MonoBehaviour scripts

jolly token
#

Activator.CreateInstance

frozen imp
#

Pass game object to Test method and use it in Debug.Log context parameter, you'll find your copy clicking on the console message

tired creek
#

Is there a wise reason as to why not make a console like that, instead using inheritance?

#

also I could skip the struct part theoretically

#
using System;
using System.Collections.Generic;
using System.Linq;

public class Console
{
    Dictionary<string, Func<string[], bool>> commands;

    public void ProcessCommand(string input)
    {
        string[] splitIntoCommands = input.Split(';');

        foreach (string command in splitIntoCommands)
        {
            string[] splitIntoArguments = command.Split(' ');

            commands[splitIntoArguments[0]].Invoke(splitIntoArguments.Skip(1).ToArray());
        }
    }

    public void RegisterCommand(string keyword, Func<string[], bool> function)
    {
        commands[keyword] = function;
    }
}

So it would be like that. Any reason thats not how its done in all the online materials on the topic I could find?

tender light
fresh salmon
#

Just be aware of the exceptions this might throw, for example when you enter an invalid command, this will throw an exception on the line where you index commands with the split string

upbeat path
#
            commands[splitIntoArguments[0]].Invoke(splitIntoArguments.Skip(1).ToArray());

this is horrible

scenic forge
#

not how its done in all the online materials on the topic
I'm more curious about this and the comment about they do it "using inheritance"

fresh salmon
#

They probably do it the more OOP way, where each command derives from a base one, allowing more features to be added like argument validation

scenic forge
#

Oh for the commands, I thought they meant inheritance for the console.

tired creek
#

aside from the fact it throws exception on invalid command

upbeat path
# tired creek why
  1. LinQ, which I hate
  2. Unnecessary, ArraySegment should do the job
  3. Lots of GC
tired creek
#

true, linq is unnecessary there

tiny pewter
#

write a simple parser and build a trie of command can prevent invalid input and even show suggestions
but node of trie quite "big" in memory (4*number of char supported+4 or more byte) suppose you trie is "array implementation" (pooled in array)

upbeat path
#

do you mean tree?

tiny pewter
#

In computer science, a trie (, ), also called digital tree or prefix tree, is a type of k-ary search tree, a tree data structure used for locating specific keys from within a set. These keys are most often strings, with links between nodes defined not by the entire key, but by individual characters. In order to access a key (to recover its value...

upbeat path
#

man, someone needs to learn to spell

jolly token
tired creek
jolly token
tired creek
#

yeah but that seems to me like an awful lot of classes for what is essentially keyword-function pair

jolly token
#

Well nothing really wrong with having many classes

tired creek
#

uhh I guess

#

I try to keep things minimal

jolly token
#

You can probably easily make generic SimpleCommand that takes your delegate

#

Then change it to regular class when you need it

#

I don’t see “minimal” as opposite as “modular” though

tiny pewter
#

i will just having some

struct command{
  char*prefix;
  char (*process)(char*args);
}
```simple.....
tired creek
#

except I figured for now I can skip the struct step, until my functionality is required to be more complex

urban warren
#

Hey, so I am working on a editor that automatically places platforms for a platformer along a spline. I am trying to figure out though how to determine if a given placement for a platform is 'valid' (reachable) by the player. Any suggestions about how to go about this?

sly grove
humble leaf
#

Honestly, it's probably easier to eye ball and test it. 🫥

urban warren
urban warren
humble leaf
#

Yeah, not sure. There are too many questions to answer with making something super procedurally driven like that. I would personally probably start by manually answering the "how far can two platforms be", and use that distance as a way to check two points along a spline.

#

There are just too many other things that go into a platformer that making a whole platform placing tool is going to eat up so much time. Unless the game is only about moving platforms. 🙃

urban warren
#

Yeah makes sense.

sleek marsh
#

you could use the kinematic equations to figure it out

jolly token
urban warren
#

Ahh, that might work. Though I will have to check if the character controller is actually using any form of physics, or if it is all manual. Good idea either way though.

sleek marsh
#

it should work even if it doesn’t use physics

#

as long as the player has a speed and jumps in a parabolic shape then the equations will work

urban warren
#

Cool. Do you happen to have any suggestions for where I could find such functions? This is the type of math I am very bad at. (If not that's fine. I can search for them my self)

sleek marsh
#

there are only like 5 of them so ya i have to send you to google

soft mica
#

I'm reviving a project from 2017 and upgrading to 2022 lts. I'm in the process of switching to the newer netcode implementation because it seems like it'd simplfy implementations.

I'm working through moving my messaging to using the rpc mechanism and running into an error where I get my clientrpc "does not exist in the current context". I have both client and server functions in NetworkBehavior inheriting classes, and both specify the attributes and correct naming convention. I'm clearly missing something that is probably obvious in the examples and tutorials online but I'm not sure what that is...

granite bane
soft mica
#

Ah thanks I didn't see that channel

humble carbon
#

Not sure which channel is the most appropriate. working on a unity game with mapbox and trying to build to iOS. I had an issue with the line #import <MapboxMobileEvents/MapboxMobileEvents.h> which couldnt be found. I moved the contents of MapboxMobileEvents/Include/MapboxMobileEvents to MapboxMobileEvents and then changed the <> to quotation marks. I am now getting an error Library not found for -lUnityARKitFaceTracking and Linker command failed with exit code 1 (use -v to see invocation)
I dont have a ton of experience building to iOS and im wondering if anyone has a solution for this. I also dont need to include face tracking in my application, since I have no need for it. Does anybody have any ideas for how to fix this?

potent roost
#

Hello, I have a problem. I want to call UnityWebRequest during build time in console mode but now I didn't get a response. If I do it just in editor then it works well. Could you tell me if is that possible?

upbeat path
potent roost
upbeat path
#

time to build in some Debugs

potent roost
#

for coroutines I used EditorCoroutineRunner

upbeat path
#

but to answer your original question, if the console is attached to the internet then yes it is possible

#

you cannot have Editor code in a Build

potent roost
#

I know

#

but it is during a build time

upbeat path
#

you mean you are calling WebRequest as part of your build process?

sly grove
#

During an actual build?

potent roost
#

Now I want to start building and send some data at end of build process

sly grove
#

Why does it need to be a coroutine if it's during an actual build?

#

the point of coroutines is to maintain interactability during some process

#

you don't need to be able to continue to interact with the editor during a build

potent roost
sly grove
#

you don't need a corotuine to call UnityWebRequest

upbeat path
#

and what do you mean by 'console mode'?

sly grove
#

I think they mean headless mode

upbeat path
#

confused me I thought they had built to a games console

potent roost
#

sorry, I forgot a name of this mode

sly grove
#

UnityWebRequest is designed for asynchronous use during playmode.

upbeat path
#

still you must be getting a response code from the WebRequest

potent roost
sly grove
#

wdym

potent roost
#

in my case, when I use EditorCoroutineRunner and UnityWebRequest in Editor to connect everything is fine. But the same code didn't work during build process.

upbeat path
#

but what is failing. you started by saying it was the webrequest, now you are saying it's the coroutine itself?

potent roost
#

when I put Debug.logs then Unity didn't call a function with UnityWebRequest

upbeat path
#

so why is webrequest relevant. it's the call of the method that has failed

dusty wigeon
sly grove
#

instead of using EditorCoroutineRunner (which you don't need), just make your web request synchronously

upbeat path
sly grove
#

this is the build process not a unity player build

#

but I still don't think that EditorCoroutines work in headless aka batch mode

upbeat path
#

never even thought of doing it

upbeat path
sly grove
#

I think there's trying to use editor coroutines BECAUSE they see UWR as the only way to make an http request and they need a coroutine to properly wait for such a request to finish

dusty wigeon
upbeat path
potent roost
#

Thank you for your help, I will try different coroutines or maybe a different approach. I write if I will need more help.

sly grove
#

The build is your game

#

The build process is the Unity editor BUILDING the game

#

Oh sorry

dusty wigeon
#

I think you are misunderstanding what i'm saying.

sly grove
#

Misread

#

Yeah mb

upbeat path
#

just realised why it does not work, EditorCoroutines are multi threaded, the headless build process is single threaded

dusty wigeon
#

Can you just not do a while(...) then ?

sly grove
#

You could but I hate the idea of a busy loop...

#

Also IDK if UWR actually updates its state on a different thread or not

upbeat path
#

@potent roost you might get away with using HttpClient

mild sentinel
#

How would I go about making seamless metroidvania-like scene swaps? Like, when you exit a level, it pans the camera to the next level. I'm thinking of loading scenes additively and unloading scenes that are more than 1 exit away. (I'm using one scene per level for organization) Though, I'm not sure how I should place the loaded scenes so that the exits line up perfectly? Also how I can easily select scene objects?

upbeat path
mild sentinel
#

yeah I knew that. I was asking if there was any way to automatically set the content to be lined up

upbeat path
#

no

mild sentinel
#

or if i'm obliged to construct the scenes so that they all line up by myself

upbeat path
#

you have to do it

mild sentinel
#

alright

mild sentinel
# upbeat path you have to do it

do you think it's going to be resource intensive if I just construct the entire map in one scene? I plan to have a pretty big map so idk what to do honestly

#

if I do multiple scenes it might be really hard to know exactly where to place the tiles

upbeat path
#

to make one map is going to take a while to load the scene. it's really not that difficult to place the objects as you can have multiple scenes loaded in the editor at the same time

mild sentinel
#

how am I supposed to know where the tiles of the previous level are when making a level (without having to look back)? since it needs to be lined up

upbeat path
#

sorry, did you not read what I said, you can have multiple scenes loaded in the editor at the same time

mild sentinel
#

oh yeah sorry I don't know why I didn't understand that

upbeat path
#

if you want to make it easy then add a gameobject in scene1 (Exit) and a GameObject in scene2 (Entrance) make all gameobjects in scene2 children of Entrance then when you load scene2 set Entrance.position to Exit.position. Perfect alignment

icy field
#

hey, in my space strategy game i want to set waypoints for the units with the mouse by clicking at the point in the scene where they should go, but it's a space game so there is no ground, and i want to also have the y axis so not all units at the same height. the player can change the y position with key input, but where do i get x and z from? any ideas? (sorry if it's a stupid question :D)

upbeat path
#

the x and y are not a problem, you can get those from mouse position then screen to world point. The z is more difficult if you are not clicking on an object

icy field
upbeat path
#

then you are going to need to interpolate z using the start position and the eventual destination position

dawn kettle
#

Can someone help me with an Inventory system. If you are experienced with that stuff please DM me. I really need the help.

humble leaf
dawn kettle
#

And an inventory system isn’t beginner with all due respect

dawn kettle
#

Yeah 3 months ago

humble leaf
#

It's not advanced. These channels are for people who can already code and need to have a conversation about what they're doing.

Beginner is for people who have no idea what they're doing. Ask your question there with details and your attempts.

dawn kettle
#

Okay

steel snow
#

how does mesh combine work if you have meshes with submeshes

#

i cant seem to get it to merge them correctly

#

if i make it combine submeshes then each mesh is alternating between submesh materials

#

if i dont then it dont really combine properly

umbral trail
#

you'll have to combine all the submeshes for each material

steel snow
#

how though

#

im duplicating a mesh prefab alone a spline

#

but want to combine all these meshes into one mesh

#

i cant figure out how to correctly combine each submesh seperately

umbral trail
#

the CombineInstance lets you specify the submeshIndex

#

so you'll have to go through each mesh's submeshes, check their materials and organise them into separate lists of CombineInstances

steel snow
#

🤔

umbral trail
#

then combine each list into a mesh and assign the associated material

steel snow
#

that sounds confusing as heck

#

why cant they just have it understand if its the same mesh object that im combining that it should just merge it into one mesh with the same submesh formatting

#

probably the one thing that people would use it for they dont even support the feature

steel snow
#

im not using gameobjects just mesh classes

#

😦

#

my plan B is to generate two seperate meshes entirely rather than one with two submeshes

#

then combine them - that might be simpler

brisk minnow
#

alrighty.... over the whole week, i pretty much exhausted almost all of my ideas, so i am presenting myself here with a frozen editor.

the story:
so, my game has a lot of sprites that i've been turning to 2d colliders, but because of how long it takes to get them all done, i've been working on setting up a way to automate creating polygon colliders to the sprites. i've came across this nice free asset on the asset store that handles the bulk https://assetstore.unity.com/packages/tools/physics/advanced-polygon-collider-52265
this works actually super good... gave me polygon colliders right on the very pixel edges of the sprite, which was exactly what i wanted

the problem:
until you use it on specific sprites that seem to have a non-random reason for causing the unity editor to crash upon add component.

the intention
so when i attach the component to the gameobject, the intended result should have been:

  1. checks if a 2d polycon collider exists and makes one if it isnt,
  2. then updates the points to fit cleanly around the sprite

the request for help
i have attached one of the few sprites in question that caused my editor to crash. i've tried in unity 2018.4 and 2021.3. at least 2021 realizes it's freezing.

if anyone whose good at figuring out these sort of bugs could enlighten me and maybe point me in the right direction to solve this, that would be wonderful.

Get the Advanced Polygon Collider package from Digital Ruby (Jeff Johnson) and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

sacred dew
brisk minnow
rancid viper
#

Is it possible for a sprite mask to affect only one specific object without using layers, with configuration controlled via a script?

gritty python
#

Is using texture array a thing for a skinned mesh merger?

#

Is it viable? instead of atlas

tired fog
#

Can someone help me understand this?

#

The render thread says to be 1.5 ms on the game stats windows

#

however on the profiler, most of the time is spend on waiting for signal

untold moth
#

Render thread and GPU processing time are 2 separate things.

tired fog
#

Since most of my gpu processing is done through command buffers, I thought that meant that it was counted as the render thread

#

What is render thread then?

#

Also, every so often there's a huge spike by unity editor, is this normal?

untold moth
#

I'm not 100% sure, but I think it builds the command buffer.
Then the command buffer is executed on the main thread(?)🤔

tired fog
#

im not sure either, it seems that if I click on GPU Usage, the values seem to be more precise, things change

untold moth
#

Executing the command buffer means that the CPU is issuing commands to the GPU and waiting for it to complete them. That's the "wait for present" that you're seeing.

tired fog
#

But in theory, the command buffer will just schedule the calls for once the rendering pass happens its executed in order

scenic forge
tired fog
#

Doesn't give more info

untold moth
#

Change the profiler to editor mode.

tired fog
#

Ah got it

untold moth
#

You can't stop it, because that would freeze the editor.

dusty wigeon
untold moth
#

That too. But sometimes fixing the editor issues worth it to make the development smoother.

dusty wigeon
#

Also, High Render Thread times usually means a lot of object that needs to be processed. Reduce the amount of object by manually culling things that are not visible. Like interior of a house, a cavern or a far aways Point of Interest.

tired fog
#

This is what Im getting on the editor

dusty wigeon
untold moth
tired fog
tired fog
#

I will try to profile a build and see

untold moth
dusty wigeon
#

Probably because it does not have a Network component.

humble leaf
#

(where someone answered your question)

bronze lark
#

Hey, where do I find the scripting reference for UGUI?
I can only find the old one, and the manual for the new one (1.0.0, package version). It's pretty broken.

#

Like, this is the generated doc and the ACTUAL doc is worse than thiis.

#

😦

#

compositionString is not a numerical value, of course.

#

(extremely sloppy documentation)

dusty wigeon
bronze lark
#

I'm not going to reverse-engineer their code.

#

But this is a basic event/property, this ought to be documented somewhere.

dusty wigeon
warm mica
#

Unity says Unity Objects shouldn't use Null propagation ?
Why though ? anyone know?
Because it works fine, also thats Null Conditional.. I thought it was Null Coalescing that didn't work on components ?

dusty wigeon
#

Also, you could say what you are looking for.

warm mica
dusty wigeon
#

The object could be considered null, but it is not really null.

sly grove
bronze lark
warm mica
sly grove
#

unfortunately yes

warm mica
#

tragic

sly grove
#

Instead of overriding null all those years ago they should have just written public static bool IsDestroyed(UnityEngine.Object obj)

#

and we wouldn't be in this mess

bronze lark
warm mica
#

time to change all the scripts dam..

#

thanks!

sly grove
#

idk why I sent the wrong link

#

and the search indeed works

bronze lark
bronze lark
#

And as you can see, these are ALL undocumented.

sly grove
#

Works for me

bronze lark
#

But yeah ok, so nothing changed since Unity 2018

sly grove
#

they're documented - they just have no useful info lol

bronze lark
#

They have 0 documentation that is beyond type inference.

#

The decompiled source code has more than that.

sly grove
#

YOu want to see undocumented try the implicit conversion-to-bool operator for RaycastHit2D 🙏

bronze lark
bronze lark
#

I'm pretty appalled at the quality of this, I didn't realize UGUI was in such an unfinished state.

#

The docs for UIToolkit are almost better. (if the tech wasn't garbage)

#

Thanks though, I will have to keep trying to solve this. 🙂

#

This one helps. 😛 That's the doc for the old UGUI, the one before TextMeshPro.

#

There's <inheritdoc/> for a reason... sigh.

#

Still can't solve it. It unreliably selects the wrong characters (swallowing the one that I communicate in from input system after activating it)

#

Just randomly trying fields, I'm glad this isn't C 😛

dusty wigeon
#

Maybe you should try to isolate one and reduce as much as you can your code.

sly grove
#

Basically - what are you trying to achieve here?

dusty wigeon
#

Do you use the EventSystem ?

bronze lark
bronze lark
# dusty wigeon Do you use the EventSystem ?

Yes, but now I'm using ActivateInputField, this fixed the first issue that the focus wasn't reliably returning on 2nd or 3rd use of the filter.

But the first char is always selected and thus lost.

#

Even with hax like this. (of course I WANT the selectall feature then the field is focused by mouse at a later time)

#

Got it. Must be called in EXACTLY this order:

public void Open(char start_value)
        {
            input.text = start_value.ToString();
            gameObject.SetActive(true);
            input.stringPosition = 1;
            input.ActivateInputField();
        }
#

Oh goodie. It works for all keys, except for W, A, and S. (but it works for D)
(I'm serious, tested the entire keyboard, whoa. w, a, and s retain their focus)

#

I have a theory, EventSystem may interpret these "move" events as cursor navigation. Doesn't explain a, but might explain w and s.

#

Yes, that was it.
So the REAL problem is in my event handler that treats move letter key the same as a input key, but... my event handler is just Keyboard.current.onTextInput unity_think. That doesn't even have a concept of "Move" or "UI/Navigate".

Also, if I do this with the cursor keys, it doesn't cause the focus to stick, but it does move the cursor.

fallow eagle
#

W, A and S event may be consumed by something else ?

stoic otter
#

Visual Studio his intelisense becomes slow when we added a package (the package yarn)
when we delete the YarnUnity.DLL visual studio becomes faster? (we use visual studio instead of code)
does anyone has a idea how to solve this because we need this package and this DLL?

mighty dagger
#

How do I debug XCode Simulator instance or app running in iPhone? I have a case where I click and do some raycast check. And this works for me in Unity, but not in XCode Simulator or iPhone. The XCode build is totally unreadable to me.

sly grove
steel snow
austere jewel
steel snow
#

i did a quick experiment with it, it seems to not remove the original GameObjects and merge it into one ? maybe i am misunderstanding how it works

#

does it still do it but keep the original gameobjects visible in the heirarchy

austere jewel
#

I haven't used it for like... a decade, I remember it as being manual and returning a combined object but the docs read like the combined object is internal and the original objects stay there unused

dusty wigeon
#

Can you just not merge the array (triangles, vertices, normals) into one to combine a mesh ?

mighty dagger
#

Is "Debug" enough to have the simulator appear there? Do I also need "Development build" and "Script debugging"?

austere jewel
young shard
#

How do I do this in unity?

mighty dagger
#

Finally it worked, but the debug build starts so slow...

#

I wonder if it's because of my code, but on the other hand the Release build starts almost instantly

sly grove
mighty dagger
#

On the third hand, I haven't tried running Debug build on iPhone, maybe it's Rosetta that is slow?

sly grove
#

yeah add in emulation and 😵‍💫

smoky kite
#

Hey guys doesn't Unity suport Thread Afinity for PC platform? I only see Android on documentation. Is that correct? Thanks