#archived-code-advanced

1 messages ยท Page 15 of 1

hushed moth
#

I get it, but still, I can receive almost real-time webrtc media stream in 1920x 1080 w/o problem, but when I change to 4K the fps goes down to 1

undone coral
#

there's a level limit for it

#

did you author the webrtc signaling yourself?

#

@hushed moth

#

or are you using a pre-existing relay of some kind?

#

or hwat is it?

hushed moth
#

lets say half-half
I had a problem with the encoder, in obs, if the encoder is nvidia nvec x264 then google blocks it, it only works with x264 encoder + profiler = baseline

hushed moth
#

looks like the ffmpeg recode solved the problem, but still, I dont think that setting the texture in each receive is a good solution

undone coral
#

but all your answers have been like this

#

you have to just say it what it is or that's it

#

i can't help you if you don't tell me straight clear answers with truth

hushed moth
undone coral
#

and i'm the only person who knows about any of this stuff

#

so it's your call

hushed moth
#

i will also look into the suggested branch

undone coral
#

okay, i think i can't help you anymore i'm sorry

west jolt
#

Hey guys, is it possible to clone a prefab and make changes to it before instantiating it?

quartz stratus
jolly token
west jolt
#

It's a small change, but this change is always different, which is decided at runtime. Alright, I guess there's no other way besides instantiating it first in a way that allows me to do the changes afterwards. Cheers :)

gilded shuttle
#

damn a real discord mod uh oh

gilded shuttle
#

Good point my friend thank yoh

warped mural
#

Hello all, I am working on a particularly mathematic game in Unity and I need to write some tests, I wasted far too much time tracking a math mistake through the grapevine.

I want to ask if it's possible to add each MyClassTest next to MyClass so that I have them together at all times, regardless on how I choose to refactor the folder structure.
I saw some asmdef shenanigans are required so I am thinking perhaps it's impossible. But I still want to have it like this as my scripts hug my prefabs where I use them 1:1.

Thank you!

torn basalt
#

Sup room

jolly token
rich estuary
#

Heyas. So wondering if anyone has had an issues with using Unity's Device Unique Identifier (UnityEngine.SystemInfo.deviceUniqueIdentifier). This is supposed to give a unique HASH from their device hardware (except for iOS), but I'm starting to think that it's maybe not unique as the documentation does not mention anything for Linux based platforms (https://docs.unity3d.com/ScriptReference/SystemInfo-deviceUniqueIdentifier.html)
I have implemented an auto login system based off their device Id for the game I'm working on (using PlayFab), but now that we have a higher influx of players after going public free-to-play, I'm noticing some players can login to another players account due to possibly having same deviceId, so if anyone has a better understanding on how this device Id works, that'd be appreciated.

pliant crest
#

just have a token

jolly token
pliant crest
#

this is pretty common pattern however

#

inheritance based game design

jolly token
#

Convention-wise I like this better
other.TryGetComponent(out ISomeInterestingInterface interfaceCommonName)
Anyways of course, that's good way of abstract components ๐Ÿ˜„

pliant crest
#

from a C# standpoint always use the generic method if you can

jolly token
#

It is generic method

pliant crest
#

thats not what generic means thou

#

๐Ÿ˜

#

you are using the literal definition i'm assuming

#

yeah this sounds good in theory

#

eventually you hit inheritance hell

#

and go there must be a better way

#

and thats where entities come in

#

with the whole ECS pattern

#

yeah i understood your intention

#

the main problem with inheritance is, its really hard to build an object dynamically

#

you can't create classes dynamically thou?

#

unless you pre create all combinations of them

#

of course

jolly token
#

ECS is great but it's not swiss knife

#

Always can do AddComponent ๐Ÿ˜„

pliant crest
#

yeah but thats no longer inheritance

#

so if you wanted a collision handler on your object now

#

you have to go through components

#

i'm just referencing this

#

on collision grab the ICollision handler which you can't dynamically add to your object

jolly token
#

Inheritance is one of tools to abstract things

pliant crest
#

unless you add the component

jolly token
#

There is no silver bullet ๐Ÿค”

pliant crest
#

what do you mean who cares about dynamic lol

#

i'm not talking about literal dynamic keyword

#

i mean like if you had a rpg player who suddenly got a shield

#

you can just add IShield or something

#

but only as a component

#

shrugs does it matter?

#

yeah but what i'm saying is you are already using the C in ECS

jolly token
#

I contribute to Svelto.ECS and there we don't allow dynamically adding component
It's not really ECS thing, it's just different pattern
If you need to add or remove some feature dynamically, you need different approach

pliant crest
#

you have an entity and it must be created with all components

#

so you can't add or remove components from that entities life time?

jolly token
#

It needs to build with pre-defined entity descriptor.
Yes you can't add or remove components

pliant crest
#

hmmm

#

i guess the question is why

#

sounds like an arbitrary restriction

jolly token
#

It's for performance, To optimize memory structure

pliant crest
#

but shouldn't that be left up to the consumer to decide

#

whether or not they want that particular entity to be optimized or not? (in that way)

jolly token
#

But by supporting it we'd have to support different type of memory layout ๐Ÿค”

jolly token
#

I'm thinking it as characteristic of Svelto.ECS

pliant crest
#

how do you add or remove functionality from an entity - unless you have to destroy it and recreate it?

#

and if you have to destroy it and recreate it how does caching work

#

cause alot of ecs is reusing memory space

jolly token
#

Have flag in component, or put it in filters, or change groups that can be queried from

pliant crest
#

so that means every single functionality possible must be attached to the entity

#

and just have something to disable it (flag)

jolly token
#

Yes

pliant crest
#

i guess its just a different way of thinking

#

not a fan of it however

#

i could see the benefits for extreme performance

jolly token
#

Yeah you can get very optimized memory layout if everything is statically determined

#

It may cost your productivity, yes ๐Ÿ˜Œ

pliant crest
#

also costs query time

#

if there are lets say 100,000 units with some sort of "debuff" component even thou they aren't active

#

you'd have to find the active ones

#

unless you track that real time

#

but then that costs you space

jolly token
#

Depends, user can move entities between query groups.
So user can have debuff-active group and only query from there

pliant crest
#

yeah its kinda like indexing

#

so its either cpu cycles or memory (small amounts)

jolly token
#

Kinda. It still supports indexing feature separately to support some less optimal cases
But yeah always have trade off

undone coral
#

if you uninstall and reinstall it on iOS, it will not be the same

#

unless you obtain the right entitlements

#

you are better off generating an ID and storing it in the app's documents for it to persist

#

you should probably use an identity service's pre-existing guest or device accounts. for mobile users this is usually centered around a message to their phone number

undone coral
#

you can also write whatever you want wherever you want, and call it wherever you want

#

if you want the tests in the script, go for it

rich estuary
rich estuary
#

But it would mean that users on a platform that does not support unique identifier would mean it is now unique

pliant crest
#

for no reason

#

just given them a login token and save it to their system if they want to remember me (after successful login)

#

cause what happens if they do this on a public device

#

kinda stupid

rich estuary
#

Right yeah good point, like at a cafe.
I kinda wouldn't just thought that storing their login token in their options file for example would be bad as well, incase someone else gets their hand on options file and just copies the key

pliant crest
#

if you hit remember me

#

on a device someone can steal

#

thats kinda on you

#

but thats true for any login token right now

#

like i could ask for or steal your discord token

#

and just pretend to be you

#

(just to clarify this is hypothetical and i in no way want it)

rich estuary
#

Yeah fair enough. Good point.

pliant crest
#

the good thing about tokens is you can have expiry dates and people can invalidate them

#

cause you can just generate a new one every x days

rich estuary
#

So you'd recommend generating a token separate from any device identifiers, and just storing that if they hit remember me

pliant crest
#

yeah

#

this way you can handle collision server side as well

#

(in the rare case it does)

rich estuary
#

Yeah makes sense.
Do you have a recommendation for how I should generate that token? (C#) Like basing it off certain hardware serial numbers, or something like the current date where it's a one-time creation that will be completely unique?

rich estuary
#

Yeah had a feeling youd say that haha

pliant crest
#

Guid.NewGuid()

#

lol

rich estuary
#

Yep

#

Thought so

pliant crest
#

you want it to be changable

#

so you don't wan it to be based on anything

dapper cave
#

is DrawInstanceMesh still the fastest way to display many times the same thing or is there a faster way now in 2021?

livid kraken
#

So lets say I want to pass a NativeArray<uint> to a c++ funtions that has unsigned int* destination as the parameter. What I have to do is (IntPtr)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks ( myArray ) ; Is this correct ?

#

how do I declare the function on the c# side? I dont want to wrap everything in unsafe, passing the IntPtr results in a sigsev. Not using NativeArrays and simply passing a uint[] works fine

#

Idk what I'm doing wrong with the nativearrays

maiden turtle
#

probably make a couple of adapters for the functions that you need, taking in native arrays

#

or use unsafe

stray torrent
#

Hi guys, I'm making a unity project that requires external dependencies aka plugins. I would like to know what is a way in unity to deal with external dependencies. Is there a some kind of package manager as npm for unity? So any new developer, who clones my project can install all required dependencies with a single command. Because now I'm forced to install all dependencies manually by clicking on unity package files and importing it.

maiden turtle
stray torrent
#

and what if my packages are like hundreds of megabytes?

stray torrent
#

Got it, thanks

pale pier
stray torrent
#

For example Zenject doesn't or does partially

livid kraken
maiden turtle
#

maybe you don't convert the length right or something

#

you can pass the pointers, just make a wrapper function that encapsulates the pointer business so that you don't have to put unsafe everywhere but just in that function

#

make the function take a native array

#

and do the pointer business there

maiden turtle
stray torrent
#

good point

maiden turtle
#

if it's nugets, I'd suggest managing them with a custom script

#

nugetforunity exists, bit it's meh in my experience

stray torrent
#

so I can just add zenject git repo as submodule to plugins folder

#

and whenever I clone project again, I'll just go git submodule update

maiden turtle
#

basically yeah

stray torrent
#

and it will fetch it for me

maiden turtle
#

if it's possible, it's usually a good approach

stray torrent
#

but what about building library?

livid kraken
stray torrent
#

Are there any pitfalls with that?

maiden turtle
somber swift
stray torrent
#

well, if I install library from unity asset store / or by downloading it manually, it comes like a built binary, no?

maiden turtle
#

oh you mean restoring the cache

stray torrent
#

while in gitsubmodule it's just a code

maiden turtle
#

so what? is that bad?

#

if it's in a separate asmdef, it would get cached and only build once anyway

stray torrent
#

I mean that code would be build on my local machine and there might be problems with environment or no?

maiden turtle
#

i guess it depends on the project, but I'd expect it to just work

stray torrent
#

okay

livid kraken
#

@maiden turtle so this is the function on the c++ side c++ size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, unsigned int options, float* result_error); I have it wrapped like this cs [DllImport("meshoptimizer.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)] private static extern UInt64 meshopt_simplify(NativeArray<uint> destination, NativeArray<uint> indices, UInt64 indexCount, NativeArray<float3>[] vertex_positions_data, UInt64 vertex_count,UInt64 vertex_positions_stride,UInt64 target_index_count, float target_error, uint options,float[] out_result_error); if I use a simple uint[] instead of the native array stuff it works as expected so I'm guessing the pointer passed to the native array does not point directly to the data

maiden turtle
livid kraken
#

yes

maiden turtle
#

it's weird to me that it works at all. I'm not sure on the details of function signature mapping, but to me these two look completely different. an int* is not the same as a NativeArray<int>. let me consult the docs

#

a native array is pointer + length

#

afaik

livid kraken
#

well the function itself is made to take the pointer of the first element and the size of the collection and iterate over that

#

so it works exactly as expected when passing in a uint[] is it's a pointer to the first element anyways( I think) not sure what NativeArray points to

#

I want to get the NativeArray part down since I'm going to have to spin up jobs calling this dll in the future

#

and I have to use this new mesh API

maiden turtle
#

it would appear to me it passes the pointer to the array object, not the array data. have you actually tried iterating over data and confirm it works?

livid kraken
#

iterating over what data ?

maiden turtle
#

if you pass a uint[], you say it works. by that you mean the code on the other side gets a valid pointer?

livid kraken
#

yes it also returns valid indicies that build a valid mesh

maiden turtle
#

because arrays are reference types in c#

#

aka pointers

livid kraken
#

so I can confirm that passing uint[] works fine

#

also it seems I cant pass a IntPtr struct to a int* in c++

maiden turtle
#

again, idk the details. ehat I'd do is I'd replicate the signature perfectly, make it unsafe, and write out a bunch of adapters for native arrays, then it would work for sure

#

I can't find the relevant docs on this marshalling, i think it's called, rules right now

#

the adapter would just call the actual binding, having extracted the pointer from the native array that was passed in

livid kraken
#

I wanted to somehow avoid using a unsafe context but looks like it cant be avoided

maiden turtle
#

you can call it normally in a safe context even if the function is unsafe

#

unsafe doesn't mean you can't use it in safe code

pale pier
floral gulch
#

get_gameObject and get_transform allocate 40 B, is that a recent regression?

abstract root
floral gulch
#

hmm, is this related to my question?

undone coral
#

then it iwll work

#

the correct way to use a nativearray in your extern is

livid kraken
#

I just did a test with ``` [DllImport("meshoptimizer.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]

private static extern void myTest(uint* destination, uint count);





public static void NativeArrayTest(NativeArray<uint> data, uint count)
{
    uint* ptr = (uint*)NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks(data);
    myTest(ptr, count);
}```
#

and this works

#

it adds 1 to the native array and prints it out from unity

undone coral
livid kraken
#

your telling me that if I do ``` private static extern void myTest(ref NativeArray<uint> destination, uint count);

undone coral
#

you would use (IntPtr)data.GetUnsafePtr() in an unsafe context

#

in unity

undone coral
#

i wouldn't use the ref keyword at all here

livid kraken
#

what I did in my test is what you suggest right ?

undone coral
#

yes but i would use intptr

livid kraken
#

let me test with intptr

undone coral
#

because that's the actual type that is passed to your extern

livid kraken
#

should be UIntPtr right ?

undone coral
#

no

#

just intptr

livid kraken
#

cause the c++ side expects unsigned int*

lusty salmon
#

Good day all! I am attempting to automate a build process for hundreds of webgl mini builds. Its a single scene. Set up the decorations, build, new decoration layout, build, repeat. Using the official documentation and each time I get error CS0234: The type or namespace 'Build' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

Any ideas on how to overcome this? Is this a known issue? So far my reseach has not returned much.

Link to the doc:
https://docs.unity3d.com/2020.3/Documentation/ScriptReference/BuildPipeline.BuildPlayer.html

My code:

using UnityEditor;
using UnityEditor.Build.Reporting;

...

[Button]
    public static void TestBuild()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] {"Assets/Scenes/Dev.unity"};
        buildPlayerOptions.locationPathName = "Assets/Builds";
        buildPlayerOptions.target = BuildTarget.WebGL;
        buildPlayerOptions.options = BuildOptions.None;

        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
        {
            Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
        }

        if (summary.result == BuildResult.Failed)
        {
            Debug.Log("Build failed");
        }
    }

Any help would be greatly appreciated!

undone coral
#

as a value

#

since structs are passed by value in c#

livid kraken
#

so then who will do the vast from void* to unsigned int* ?

undone coral
#

x-files music

undone coral
abstract root
undone coral
#

the only reason to do this is to make it bulletproof

#

this is the example in the unity source i found

#

it's actually very rare to pass native arrays to extern declared methods

#

in their bindings

#

they usually package it all in a struct as with the async readback api

#

using IntPtr means it's unambiguous how C# should marshal i think

lusty salmon
abstract root
#
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build.Reporting;
#endif

...

#if UNITY_EDITOR
[Button]
    public static void TestBuild()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] {"Assets/Scenes/Dev.unity"};
        buildPlayerOptions.locationPathName = "Assets/Builds";
        buildPlayerOptions.target = BuildTarget.WebGL;
        buildPlayerOptions.options = BuildOptions.None;

        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded)
        {
            Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
        }

        if (summary.result == BuildResult.Failed)
        {
            Debug.Log("Build failed");
        }
    }
#endif
lusty salmon
#

Gotcha. Thank you I will try that now

livid kraken
#

Thanks doc if anything this will make the code cleaner

undone coral
#

are you trying to turn N assets inside a viewer into N webgl builds?

balmy trellis
#

hi all, does anyone have any pointers to making a good pre commit hook for c#? I'm trying to stop my devs from committing if there are any stylistic or typo errors in their code

lusty salmon
#

Creating mini scenes for a client. Using an algorithm to create all possible combinations and spit them out as webgl builds little dioramas

#

@abstract root Thank you but wrapping the editor bits did not work

abstract root
#

any specific errors?

lusty salmon
#

The same, claiming I am not using UnityEditor.Build, which I am

abstract root
#

is the script inside a separate assembly?

flint sage
#

You can't have any references to UnityEditor outside of Editor assemblies, the error says that you are and thus you need to exclude those from builds

lusty salmon
#

No, It is in the scripts folder

lusty salmon
flint sage
#

Nixa gave you a good example on how to exclude things, you should do that for everything that uses UnityEditor

lusty salmon
#

I did that, no effect

#

Unless I missed something

flint sage
#

Or move your editor only code to an editor assembly, either a folder named Editor or if you're using AsmDef files then you need to create an asmdef and mark it as editor only

#

Yes you probably missed something

#

the error will point to where it found an issue

lusty salmon
#

This is where it says the issue is:

using UnityEditor.Build;
using UnityEditor.Build.Reporting;
#

Not sure how I could have possibly messed that up

flint sage
#

Looks like it's not wrapped in an #if

lusty salmon
#

The include lines need to be wrapped as well?

flint sage
#

Yes

lusty salmon
#

I wasnt aware of that

#

Thank you

flint sage
#

It's in Nixa's example ๐Ÿคทโ€โ™‚๏ธ

lusty salmon
#

I see, I just missed that is all

maiden turtle
livid kraken
#

now to continue restling with the unity api

#

btw what the doc suggested for IntPtr also works fine at least in the test, hope so with the actual codebase as well

maiden turtle
#

yeah since all pointers are the same size, it only matters from the type safety standpoint which type of pointer gets passed

#

and if you made adapters, you wouldn't care about that anyway

livid kraken
#

so what is "safer" ? IntPtr or explicitly using the same pointer type as the c++ code ?

maiden turtle
#

Neither one ensures you got the function signature right, I think.

#

using the same pointer type, well, reflects the type

#

so imo that's better

#

but make the wrapper functions anyway

livid kraken
#

in the context of what you are talking about is this ``` public static void NativeArrayTest(NativeArray<uint> data, uint count)
{

   IntPtr ptr = (IntPtr)data.GetUnsafePtr();
   myTest(ptr, count);
}``` the adapter ?
maiden turtle
#

yeah

livid kraken
#

cool we are on the same page then ๐Ÿ™‚

#

that was how I'm making it anyways. I'm not calling the extern directly

undone coral
#

then, author it as a plugin for pre-commit

#

however i will warn you... this is a colossal waste of time

maiden turtle
#

in my experience, it's best to have a custom cli tool for all CI stuff. you could try Nuke maybe, I didn't like it much but it does a lot of stuff for you.

unborn vessel
#

hello, i'm wondering does anybody know of a way i could acquire names of the files that a folder holds? for example if i go to a special directory i can create files File1.txt File2.ogg File3.exe and so the game acquires the names and creates strings so now i have 3 strings each one named that (order doesn't matter) and if there's only one file it only acquires a single string etc.

maiden turtle
#

Directory.EnumerateFiles

#

@unborn vessel

unborn vessel
maiden turtle
dapper cave
somber swift
#

That requires some shader knowledge but should be super fast

#

Also because you have to give the object positions etc. as buffers, its really easy and fast to modify them using compute shaders

spice ocean
#

Should I always declare my classes as sealed when posible?

sly grove
#

it's just noise

#

I'd say only bother with sealed if you're making a library for other developers to consume.

spice ocean
#

Well, bother with sealed is good practice and in some cases you can gain a little bit of performance

torn basalt
#

Not sure if I am asking in the wrong channel but I ran across something and can't figure out why. I am raycasting to an inverted cube and its not returning the correct normals. A basic cube returns the correct normals but not an inverted one. The player is inside of a box

devout hare
#

You have taken into account that inverted faces also have inverted normals?

torn basalt
#

I tried using the inverse but it still hasn't returned the correct normal

#

this is what I am using

        {
            Debug.Log(normal);

            switch (normal)
            {
                case Vector3 v when v.Equals(selectedObject.transform.forward):

                    _surfaceDirection = SurfaceDirection.Front;

                    break;
                case Vector3 v when v.Equals(-selectedObject.transform.forward):

                    _surfaceDirection = SurfaceDirection.Back;

                    break;
                case Vector3 v when v.Equals(-selectedObject.transform.right):

                    _surfaceDirection = SurfaceDirection.Left;

                    break;
                case Vector3 v when v.Equals(selectedObject.transform.right):

                    _surfaceDirection = SurfaceDirection.Right;

                    break;
                case Vector3 v when v.Equals(selectedObject.transform.up):

                    _surfaceDirection = SurfaceDirection.Top;

                    break;
                case Vector3 v when v.Equals(-selectedObject.transform.up):

                    _surfaceDirection = SurfaceDirection.Bottom;

                    break;
            }

            return _surfaceDirection;
        }```
balmy trellis
jolly token
balmy trellis
warped mural
lament salmon
#

Hey, should I use DrawMeshInstancedIndirect for a custom detail renderer? I'm using DrawMeshInstanced at the moment, but noticed that a lot of other solutions use the indirect method.

sly grove
warped mural
#

Yes

undone coral
#

okay

#

and what do you want to test

warped mural
#

I have some spreadsheets that dictate the proper loot and progression rate but my actual Unity-based generation is giving me buggy results

undone coral
#

like concretely

#

because i read your original message

undone coral
#

that makes a lot of sense

warped mural
#

So my need is straightforward, I can either put Generate.cs and GenerateTest.cs in the same folder, or I can mirror my Scripts folder with a Tests folder

undone coral
#

yeah

warped mural
#

I would prefer pairing the classes together Generate.cs and GenerateTest.cs

#

otherwise I have to sync the Tests and Scripts all the time

undone coral
#

besides the aesthetics of it, why is it essential that the files be side by side

#

and why do you use the word sync? you could, or could not, write tests for any code, or no code

warped mural
#

The asmfdef is my blocker because I see everybody put all tests in a single folder

undone coral
warped mural
#

If I put all the tests in individual folders sprinkled around, I have to make an asdmfdef for each, right?

undone coral
#

no

warped mural
#

An asmdef takes the folder it's in and the subfolders and turns it into a dll yes?

undone coral
#

yes

#

are you asking how to organize tests in unity?

warped mural
#

yes

undone coral
#

you're a very experienced developer so i hear you

#

there's a particular way you want to organize the files

#

which, it sounds like it's the golang pattern to me

#

i just have to understand if this is essential

#

like besides the aesthetics of it

#

why does a ClassNameTest have to exist for every ClassName

#

and why does it have to be side by side in the file system?

warped mural
#

I restructure my project shape frequently and recently I split the code in several submodules / git projects to reuse in other projects

#

Thus I wanted the class and the test class to stay together

sly grove
#

Unity testing definitely kinda forces you into having parallel folder structures, due to the way asmdef works

warped mural
#

@sly grove I was afraid of this, but tutorials are kinda all identical and I hoped to find a solution

undone coral
#

what if you just had a file called GeneratorTests that tests all of your generation code?

#

and it's just 1 file for "all" your classes

warped mural
#

And have a 5000 line code omega class? sounds painful to update it

undone coral
#

you have a working game, usually for a less experienced programmer i would tell them that these aesthetic constraints are getting in the way of things

#

but if it's important to you to organize something in a very specific way

#

you can have the files side by side, and each their own named thing or whatever

#

it just depends do you really need Tests or tests?

#

are you going to run these automatically in a build server?

#

do you need them to correctly respect accessor visibility?

warped mural
#

I like single-responsibility classes and I structured my features in the form of:
Feature
-FeaturePrefab
-FeatureView
-FeatureViewTest (this is what I gravitate to add everywhere)

#

I will do them manually, or make a local script before doing git commit

undone coral
#

do you need a testing framework is really the question

#

do you care for any of the value that XUnit / NUnit (peer of unity's testing framework) gives you?

warped mural
#

Well, I want to do Asserts and I like the UI panel that shows me what's failed and what's succeeded

undone coral
#

okay

warped mural
#

I don't really care about the tool, just the results (painless as possible)

undone coral
#

does it matter to you if your build ships with the small testing framework dll?

warped mural
#

included inside the export?

undone coral
#

yes

warped mural
#

I guess it's fine

undone coral
#

okay

#

then you can just reference the testing framework package in your Scripts asmdef (or however you have it organized) and you're good to go

#

you can declare the tests

#

side by side

warped mural
#

how small is the testing dll

undone coral
#

well i'm not sure, but small

#

comparable to having an additional few textures

warped mural
#

Then problem solved! I get to have my cake and eat it too

undone coral
#

lol

warped mural
#

thank you @undone coral

undone coral
#

basically you're making your player assembly contain the tests

#

which are just methods with the annotation [Test] or whatever

#

in principle, it will all get stripped out in il2cpp anyway, since nothing references it

warped mural
#

I will put the contents of my Test.cs classes inside #if UNITY_EDITOR anway

undone coral
#

yeah i think it will all be fine

undone coral
#

an unsafe cast of nativearray to a void* happens to work because the first field is indeed a pointer to a buffer

#

so if you interpreted the nativearray as an IntPtr or void* unsafely, Things Would Work

#

that wouldn't be true if the declaration of NativeArray ever changed

#

if you did ref NativeArray, the method would receive a pointer to the struct, whose first field is happens to be a buffer point. so the receiving method would actually get a void**

#

no good.

jolly token
#

Can I make 'nested' class as MonoBehaviour/ScriptableObject?

#

How do I match the filename?

warped mural
upbeat path
jolly token
#
public class OuterClass
{
    public class TempBehaviour : MonoBehaviour { }
}

Outer class is not MonoBehaviour

sly grove
#

I don't recommend it

#

basically the editor doesn't know how to handle it if it's not 1:1

upbeat path
jolly token
jolly token
upbeat path
#

I cannot see that working

sly grove
#

which defeats the purpose, right?

#

the SO asset needs a file GUID to point at for the script. It won't have such a thing if the class is not 1:1 with a file unfortunately

jolly token
#

Hmmm yeah that will be shame
I can just go with interface ๐Ÿ˜Œ

#

Though It will be still 1:1 match

#

Outer class is not Mono or SO

upbeat path
sly grove
#

It won't be able to detect that sadly ๐Ÿ˜ข

jolly token
#
public class OuterClass
{
    public interface ITempBehaviour { }
}

public class TempBehaviour : MonoBehaviour, OuterClass.ITempBehaviour { }

I might end up doing like this, it's also fine ๐Ÿ˜Œ

upbeat path
#

that will work

jolly token
#

But it's still gonna need generic ๐Ÿ˜›
I'll post here when I sort this out

upbeat path
#

generic on the interface or on outerclass?

jolly token
#

It's gonna be on outer class and SO

upbeat path
#

be careful with builds, a lot of generics will work in Editor but get removed from a build

jolly token
#

Yeah, as long as they are being used it should be fine, but I'll make sure test them

upbeat path
#

code stripping can be an absolute bitch

jolly token
#

Interesting but I'll have to find out a better way

dapper cave
#

DrawMeshInstancedIndirect could be even

chilly nymph
#

The unity API is mostly just a wrapper for those systems to interact with GO's yes, but there's also other things like sound, UI, inputs.

#

80% of the time you don't need a Mono class.

undone coral
#

for the spreadsheet thing?

#

you can use the approach addressables does

jolly token
undone coral
#

they are never going to make the error, oh no i forgot what type this is

#

they can handle CatheiReference ref; ref.AsRow<RowType>()

#

otherwise code generation is unavoidable. you would probably want to create an IDL, and then generate the types from that using someone else's tool.

jolly token
#

With a type metadata for editor script to filter them

undone coral
#

i also do not find it that burdensome, in general, to declare the class MyClass : BaseClass<RowType> {} myself

#

if i am using your sophisticated thing, i can handle creating that file

#

i wouldn't be bummed you didn't make that for me

#

however... how are you generating RowType?

#

that's still codegen

#

tricky codegen at that

#

i've seen JOOQ's code it's nuts

jolly token
#

I don't do codegen ๐Ÿ˜„

#

User create C# class themselves

#

It's like DB ORM

undone coral
#

gotchyu fam

jolly token
#

Then I parse spreadsheet by that type user defined

undone coral
#

gotchyu famalam

#

i would suggest doing the hdrp config package approach

#

where you get a copy of a bunch of things you can customize

#

then you can give the end user the file

#
[Serializable]
public partial class DefaultRowType : IRowType {

}
#

that they can edit... they're going ot have 1 row type most of the time

#

then include a file ```cs
public partial class DefaultDataHolder : DataHolder<DefaultRowType> {}

#

in your package

jolly token
#

Hmmm how will it help :0

undone coral
#

DataHolder would be a monobehaviour*

#
public abstract class DataHolder<TRow> : MonoBehaviour where TRow : IRowType { ... }
#

you can actually just put both partials in your package

#

and then build your docs around filling out the partial

#

on their side, in their own space

#

since most people will have 1 row type they'll at least be able to get started easily

#

you just can't easily rename / upgrade this stuff, but that's a problem with all serialization libraries

jolly token
#

Ah that kinda thing ๐Ÿค” Isn't it basically codegen without 'gen' but manual copy

undone coral
#

or no copy

#

it's a low ask

#

protobufs ships all its classes as partial for C#

#

in case you wanna add stuff

jolly token
#
public class ItemSheet : Sheet<ItemSheet.Row>
{
    public class Row : SheetRow
    {
        // use name of matching column
        public string Name { get; private set; }
        public int Price { get; private set; }
    }
}

This is how it looks like rn

#

The thing is I'm supporting multiple importer/exporter with same object

#
public abstract class SheetScriptableObject : ScriptableObject, ISerializationCallbackReceiver
{
    [SerializeField]
    private string _serializedRow;

    [SerializeField]
    private List<UnityEngine.Object> _references = new List<UnityEngine.Object>();

    private ISheetRow _row;
}

SO's gonna look like this, I'm happy with the format itself

undone coral
#

okay so this is pretty similar to addressables

#

which is also good

jolly token
#

User can use ItemSheet.ScriptableObject type to filtered reference of SheetScriptableObject and get ItemSheet.Row through it

#

Which I'd provide with PropertyDrawer

#

So that one is pretty much settled, I have another problem, though

#

About how to support column referencing specific asset, while supporting server side assembly

#

Something like AssetPath<GameObject> is not going to work in non-Unity env ๐Ÿค”

undone coral
#

they exist

#

they're alright

jolly token
#

What is that?

undone coral
#

hmm

#

there used to be a github repo

#

with unityengine.dll and unityeditor.dll

#

stripped of externs

#

so it's just the types

jolly token
#

Sounds useful for this purpose

undone coral
#

maybe with the C# source repo it Just Works

#

okay here we go

jolly token
#

I'll either go with using mock classes for Unity, or just use generic AssetPath

undone coral
#

it is pretty painful to install the unity editor into a container btw

#

could be a huge distraction for you

jolly token
#

Exactly. ๐Ÿ˜ข

undone coral
#

although i think most innovation lies there

#

it's very tough

#

i pitched trilib guy on it too

jolly token
#

Only if there was [Conditional] for generic parameter lol

chilly nymph
jolly token
chilly nymph
#

Ah was wondering if there was hate against it.

jolly token
#

Plus making codegen configuration generic is messy XD

#

I want my libraries Vanilla as possible so it can be easily maintained

shy spruce
#

should the UserSettings directory be gitignored?

chilly nymph
shy spruce
#

I don't use GH unfortunately

#

and the project is already made

#

If you have your .gitignore handy, could you please tell me if UserSettings is included in it?

#

no worries if not

fresh vortex
#

Just Google out unity git ignore default template

#

And see if it's in it

shy spruce
#

ah yeah that's a good point -- id already done that, and am using a template, but i guess the update to 2021 added this directory. mine didnt have that. thanks

#

looks like UserSettings is indeed included in 2021

jolly token
#

It's personal settings per user

shy spruce
dapper cave
#

ComputeBuffer.GetData, is there something faster and non blocking?

chilly nymph
#

When you initialize an object you have control over what it can reference as well, as oppose to having to resort to using the api to pull a reference.

#
      SomeRegisterService(this);```
sage radish
jolly token
#

In theory, you should not create GameObject if it doesn't have "view"
Which would be physics collider or rendering component, they would only interact with physics

But if you count logical case like "Player HP went down so HP bar should decrease" as interaction then there is much more way to interact

dapper cave
sage radish
chilly nymph
#

Sure, if your system doesn't need to do that. But relying on (for an example) like a health system mentioned above you shouldn't have a GO health (just a health bar) you shouldn't be using any API calls to get a reference to anything.

#

HealthBarUI.Set(Player.Health) There's no API calls to unity, you have all direct references so I don't know why you don't think it's a good idea to "couple" one Mono to another when you can have managers / controllers.

dapper cave
chilly nymph
#

"That game object would have something that represents the health system" You're saying you would put the player health on a healthbar UI?

#

Why would you have health data on a GO?

#
       public uint health;```
#

You would pass your view a value and it would render it, right?

#

An observer doesn't need to be a GO

chilly nymph
#

"That game object would have something that represents the health system" You are saying that it represents a health system, not the health value.

undone coral
chilly nymph
#

I'm trying to explain that 80% of the time you don't need to interact through game objects (and you shouldn't). For the above example your game objects should only receive and render the value of health, there shouldn't be health anywhere in the scene as you don't need it.

#

For things like a player attacking enemies, yes that's a system that needs colliders, and you would have to use the API.

#

For a system that has only ONE enemy you wouldn't use colliders unless it was physics based and you would directly call Enemy.Hit(damage) from your Player.Attack(), or even a observer.

#

You wouldn't want to rely on another layer of interface if you can just do it by directly referencing.

#

I'm adding to your central point by saying most of the time a system doesn't need to rely on the API to get references, you can arcetect it around direct references when you can.

dapper cave
chilly nymph
#

what exactly is the cause of your in game interactions that isn't a raycast I literally just showed you Enemy.Hit(damage) from your Player.Attack(),

undone coral
#

imo you should do a rough simulation in CPU first

chilly nymph
#

void IsAttackButtonPressed(){ Player.Attack(Enemy, damage)

undone coral
#

or iteratively do the gpu work

#

what is the platform?

chilly nymph
#

Mate you have inputs.

jolly token
#

Instantiation is also interaction ๐Ÿ˜„

undone coral
#

on modern AMD and NVIDIA gpus, compute can run parallel to graphics, and in principle you can get your data same frame

chilly nymph
jolly token
#

The spawner and instance

dapper cave
chilly nymph
#

I think we're trying to explain that you don't need to use the API in most cases.

#

From a manager.

#

Static.

#

Singlton.

#

Where would you like to get it?

undone coral
chilly nymph
#

And relying on a raycast is better?

#

You're free to do what you want. I'm trying to argue that having a direct reference as opposed to relying on a API interface is better.

#

I disagree 100%.

#

But you're free to do it your way.

#

You know that relying on the API is "Middle management" too right?

dapper cave
undone coral
dapper cave
chilly nymph
#

I understand it, but your only argument as to why you prefer using the API is that "managers suck" When you're using managers.

undone coral
#

i don't know if it's realtime colliders

dapper cave
undone coral
#

or like if you have to call a method to get the mesh

chilly nymph
#

.Hit(), .Collide(), .Find() pick what you amt.

undone coral
#

it has SDF raycasting

#

but it soundsl ike you want physics objects right?

dapper cave
#

i don t know if it s realtime colliders

chilly nymph
#

But a raycast (or any other collision) is a lose manager.

#

You're literally using a manager when you use those.

#

What do you think .Hit() is?

#

Then use a Singleton.

#

Alright mate. You keep using the API.

#

What do you think Physics. is?

#

You think it's some magic code? ๐Ÿ˜„

#

I don't use managers uses manager.

#

What is the Physics. lib to you?

#

How does it exist?

#

I'm listening, you're "Barfing" at managing references but then don't acknowledge it's a standard across Unity.

#

Alright, anyways you're free to do what you want.

#

But you refuse to write one because "Barf"

#

IMO you're just relying on weaker code and adding smell when you rely on physics when you can easily contain a direct reference where you need it, but you can do what you want.

#

We don't have to agree, and that's fine.

#

To be fair your only opinion was "Barf" ๐Ÿ˜„

pliant crest
#

why would you have both Instance and Singleton?

chilly nymph
#

I think you're lost mate...

zenith ginkgo
#

Who... Actually cares?

#

this whole thread is very childish.
theres no 1 way to do something

#

Move on

chilly nymph
#

Well you should get it right, SomeManagerManager.Instance().Enemy()

jolly token
#

Manager doesn't have to be singleton ๐Ÿค”

#

Dependency Injection ๐ŸŒˆ

pliant crest
#

whether you DI or singleton i think his problem is more having to write a manager

#

sad thing is

#

this means ECS is out the window

#

cause S is basically a manager

#

would be nice if they supported DI out of the box

#

thats not what DI means

jolly token
#

As many as your contexts ๐Ÿค”

zenith ginkgo
#

Call me a sinner

pliant crest
#

i think most people have something similar

jolly token
#

For example each prefab can be each small context if they need dependencies
A combat can be context, a scene can be context

pliant crest
#

that doesn't really mean anything thou

zenith ginkgo
#

Singletons are good, if used in moderation Imo.
GameManager is the only singleton here, and it has a reference to the other managers

#
    public AudioManager GetAudioManager() => audioManager;
    public SaveManager GetSaveManager() => saveManager;``` and yes, i prefer this, instead of a property
thin mesa
#

but that's effectively the same thing as a property

zenith ginkgo
#

we all have our kinks boxfiend

pliant crest
#

why not just make it a field at that point?

#

seems like pointless ovehead

jolly token
#

๐Ÿ˜Œ It is not single point of entry if it's getting referenced from all over your code

pliant crest
#

how else do you define single point of entry otherwise

jolly token
pliant crest
#

???

jolly token
#

It should reference dependencies, not getting referenced

pliant crest
#

dependencies of what?

#

this is a wrapper around the resource

#

to give a single point of entry

#

what dependency are we talking about here

jolly token
#

Not the other way around like every other script referencing Composition root

pliant crest
#

oh if you are referring to push vs pull sure

jolly token
#

I'm talking about Dependency Injection

pliant crest
#

yeah i know

brisk pasture
#

yeah its just DI without a framework. actully prefer it this way

pliant crest
#

but whos gonna build DI

#

i was more referring to this is single point of entry

#

i didn't really care about the CR comment

#

but i see what you are getting at

jolly token
#

Single point of entry is where program or context starts, composition root can be initialized

brisk pasture
#

it just makes it easy to manage dependencies, they can be constructed at different points with the top being main, and passed down to what depends on them

pliant crest
jolly token
#

Referencing single point of entry is like calling Main from your script, which is nonsense in most of scenario

chilly nymph
#

Y'all want to fight about Scriptable Objects now?

pliant crest
#

i've still never used an SO before

zenith ginkgo
#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

jolly token
chilly nymph
#

It's actually funny, on the other discord (GDL) they advocate for SO's.

austere jewel
#

They're an awesome part of the toolkit that people should consider when implementing anything. Just like almost everything else you can use them inappropriately or wastefully

pliant crest
#

huh its probably the type of concepts i code, most of it doesn't have (large amounts of) hard coded data

#

since its mainly roguelike/lite stuff so haven't had a need for a data class

#

like the test tower defence i'm trying out right now you build your own tower

#

so there is no definition

jolly token
#

Using SO something other than immutable data is basically visual scripting ๐Ÿ˜Œ

chilly nymph
pliant crest
#

shrugs if you can't infer what i mean by that

#

then doesn't really matter

chilly nymph
jolly token
pliant crest
#

its all math formulas

#

there is however a baseline

#

for the (stats)

#

and there is no predefined wave

jolly token
#

So baseline values are just set in inspector I guess

pliant crest
#

its on a manager

#

but yes set in inspector

#

(technically its on a System but w/e)

jolly token
#

I see, nothing wrong with that if you don't have to edit or refactor values a lot

undone coral
#

you don't have to start

#

don't even think about scriptable objects

undone coral
#

the comforting, snug feels of the scripts that you finish and don't revisit, and then when you need to write new stuff, it gets added on

#

the warm fuzzy of a game getting made

undone coral
#

okay i can think of worse things:

public class managers : ScriptableObjectSingleton<managers> {
 public Func<ScriptableObjectSingleton<audioManager>> getAudioManager;
 void Start() {
  getAudioManager = FindObjectsByTag("audio manager")[0].GetComponent<AudioManagerFinder().audioManager_FindAudioManager_SO().Deserialize();
 }
}
jolly token
#

Unless you make YT video with lot of tutorial follower

undone coral
#

lol

undone coral
#

_SO is pretty authentic though

austere jewel
#

doing it on start is somewhat sane, you've really got to make some basic logic mistake in a property that means it's retrieved via Find every time it's called

rotund sorrel
#

Hello, I have a problem with collider and rigidbody. I force my ball with 2000f and it bounce off even dont hit the bound (pic1) - exactly it cant because the ball smaller than empty between two bounds.
When I force my ball with 1000f , it go through normaly.
I had test my Ball with Continous Speculative and Continoues Dynamic but nothing change

shy spruce
#

Does OnMouseEnter get called for any collider in 2D, or just the first one the raycast hits?

scarlet copper
#

Guys I have weird problem. I have a player object which is always in DontDestoryOnLoad Scene. It is a VR game. It has in Start() SceneManager.sceneLoaded event. But if a new scene is loaded all references in this script gets null. But only in the sceneLoaded assigned event method. I am really confused what is happening. I already checked with Awake and Update but there references are NOT null but in the event method they are null. And the funny part is this happens not always. Even if (gameObject) causes error

long ivy
#

looks like PlayerManager isn't DDOL after all

#

and any other GameObjects it references which aren't also DDOL will be lost when their scene is unloaded

scarlet copper
#

The references are all childs of the main gameobject. Like I wrote I used Update() to print the references and they are never null there and it happens randomly. I also checked OnDestroy.. also not invoked. In the editor I can see the gameobjects all exists and even in the inspector I see them they are assigned.

Ok I tried something else. It has definitely something to do with SceneManager.sceneLoaded. I changed to LoadSceneAsync and used complete event and there gameObject exists but in the event of sceneLoaded it shows still error.. Weird.

chilly nymph
#

Also if you can, I would suggest removing your dependency on Unity child / parent. And hold references directly to your instances.

#

A parent spwans a child, so you have your reference right there.

#

May fix some of your issues.

#

void SpawnChild() => new Child(this);

long ivy
#

how are you setting this event up?

scarlet copper
# chilly nymph Also if you can, I would suggest removing your dependency on Unity child / paren...

This is how it looks like (simplified)
Player (PlayerManager.cs)
-->Camera (CameraFade.cs)

Player has the PlayerManager script.
Camera has the CameraFade script. PlayerManager has a field for CameraFade and I just dragged and dropped dropped it like usually. Its also a prefab. So it cannot lose actually.
But still does not makes sense, why this.gameObject should be null?

But like above I said with AsyncOperation it never shows any errors. Just check the image. Async also uses gameObject and no error while in the SceneLoaded it shows error.

scarlet copper
#

@long ivy

void Start()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

private void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
    previousScene = currentScene;
    currentScene = scene.name;

    Debug.Log("OnSceneLoaded invoked");
    Debug.Log(gameObject); // this shows error sometimes

    //if (gameObject) // this even cannot work, it shows error
    //    StartCoroutine(DelayedInvoke());
    //else
    //    Debug.LogError("This gameObject does not exists...");

    //IEnumerator DelayedInvoke()
    //{
    //    yield return new WaitForSeconds(1f);
    //    camFade.SlowFadeIn();
    //}
}

// This gets called if I want to change the scene
public void TransitionToScene(string scene) {
    sceneName = scene;
    camFade.SlowFadeOut();
    Invoke("LoadScene", 1.5f);
}

private void LoadScene() {
    previousScene = currentScene;

    //SceneManager.LoadScene(sceneName);
    asyncLoadScene = SceneManager.LoadSceneAsync(sceneName);

    asyncLoadScene.completed += (ao) =>
    {

        Debug.Log("asyncLoadScene.completed invoked");
        Debug.Log(gameObject); // NEVER shows error (10x tested).
        if (gameObject)
            StartCoroutine(DelayedInvoke());
        else
            Debug.LogError("This gameObject does not exists...");

        IEnumerator DelayedInvoke()
        {
            yield return new WaitForSeconds(1f);
            camFade.SlowFadeIn();
        }
    };
}
#

And of course this one

void Awake() {
    DontDestroyOnLoad(gameObject);
}
#

The version I am using is 2021.3.4f1

long ivy
#

this doesn't match your previous code. Does the PlayerManager GO have a parent? Does PlayerManager exist in the scene as a prefab instance?

scarlet copper
long ivy
#

does PlayerManager do anything else? Is it a singleton? Is the AwakeScene ever loaded again?

scarlet copper
#

This is not even my project and not my code. I just got hired to complete some milestones but I couldn't even start because of this error ๐Ÿ˜….
However, as you can see it works with asyncLoadScene.completed event.

But I also noticed if I go into playmode if I don't get error.. so the error never comes. But if I restart and it shows error.. so it happens always. But still does not make sense for me.

scarlet copper
#

The singleton is a good hint. Let me check that

#

Omg you are right. It is a singleton and they activated the Enter Play Mode without Domain Reload. Now it makes sense.. Holy...

#

Ok, I finally figured out what's actually happening. The singleton is NOT the problem. Oh dear.. what a headache.
Since this SceneManager.sceneLoaded is a static, it does not gecleared if I replay because Enter Play Mode was activated in the project settings. So it just contains the handler and reference to the gameObject which of course is null when I turn back to editmode.

Now it also makes sense why it happens sometimes. If I change code and compile the domain gets reloaded so the sceneLoaded handler list is cleared. That's why it worked also all the time until I restart it without any code changes because sceneLoaded had one handler in the list not two with null. What a headache. I hope I was able to explain it clearly.

livid kraken
#

At this point I'm at a total loss. https://pastebin.com/1DyXju4F I know that the data in newIndicies is correct. The triangles get set, the submesh has the correct number of indicies, the bounds are correct etc etc. Yet no mesh is rendered at all. I also know that the vertex data is there and correct since I dont modify the verts at all. Wtf am I doing wrong.

torn basalt
#

wrong group sorry

fresh salmon
torn basalt
#

effort made

undone coral
#

anyway i think it's just something here that has to actually be called

#

i am not sure what it is

livid kraken
#

Lines 40 to 42

#

I set the new index count and apply the submesh to the new data

livid kraken
ionic quartz
#

Hey guys, I'm wondering if anyone has some insight in an algorithm that would create a pattern similar to this? I am planning to use this for a continuous 2d cave system

undone coral
#

did you draw it?

ionic quartz
#

Ye I drew it

undone coral
#

okay

#

you can try drawing it again, and write down the decisions you made while you were drawing it. that is the start of your algorithm

#

there are many approaches to procedural graphics generation, but the real problem is that they are incomprehensible to people who have never done it before

#

and it wont' be useful to use a preexisting one for you

ionic quartz
#

Ah that makes sense thank you

undone coral
gentle topaz
#

honestly just looks like some modified version of perlin worms

#

one pass where it mostly moves right, then another pass where it adds offshoots

ionic quartz
undone coral
#

if you like math try to express it mathematically

#

if you like updateloopese

#

you know, make a character that walks in that path

mortal orchid
#

I am using this method to change the direction of the enemy towards the player in a 2D top-down game. But the animation is flickering do you see any problem in this way of implementation?

mortal orchid
#

Nope not showing the progress. I understand that the channel is for advanced code. forget to write the description. I have edited the post

tender light
fresh salmon
#

Don't cross-post.
You'll need to provide more info, like whether you're getting the logs or not. Make a development build if needed. Check the Player logs if needed.
Ask in #archived-networking if the error comes from any networking related method.

foggy bramble
fresh salmon
#

You'll need to post the full error message, which contains the stack trace

foggy bramble
#

OK

fresh salmon
#

NullReferenceException: Object reference not set to an instance of an object
at Launcher.OnJoinedRoom () [0x0000c] in C:\Users\fdmcp\Valorant 2d\Assets\Launcher.cs:22
Error on Launcher.cs, line 22.

foggy bramble
fresh salmon
#

playerPrefab was null

foggy bramble
fresh salmon
#

That's what you're trying to solve

#

Maybe the PlayerContainer object isn't there at the time the method runs

#

Try referencing the script in any other ways than drag-drop.

foggy bramble
fresh salmon
#

Like any other object. If you're able to drag-drop, you can do all the other ways. This includes using GetComponent<T>, Find, FindObjectOfType<T>

foggy bramble
fresh salmon
#

That's why I'm telling you to try other ways of referencing that component

#

It's a networking issue, and I'm not experienced in networking, so we do the regular C# and Unity ways first

foggy bramble
#

Ok

wintry wind
#

Hi I have a script that generates a mesh and assigns that mesh to a property. When I try to Apply the overide mesh to the prefab (I want to save it to the prefab) it says that I can't because the mesh is a scene reference. But the mesh is generated by code and assigned as a property to the object. How can I do this? Do I NEED to do an editor script?

foggy bramble
dusky tiger
#

Hello my Trigger is not working ```csharp

private void OnTriggerEnter2D(Collider2D collision)
{
trsf.position = new Vector3(5, 5, -1);
if (collision.gameObject.tag == "Player")
{
Audio.Instance.PlaySFX(win);
SceneManager.LoadScene("Winning Screen");
}
}```
If I go to that trigger with my Player but it does nothing

jolly token
dusky tiger
#

I tried that but it just dissapeared

grave vortex
#

how would I change the skybox material in a custom render feature? I tried RenderSettings.skybox = newMaterial, but that set the skybox for the subsequent pass as well, would just like it in my scriptable render feature.

gray pulsar
grave vortex
gray pulsar
# grave vortex At what point would I reset it?

I haven't done much with custom render features, so I'm just guessing here. But looking at the docs, it seems like doing it at the end of your Execute method would do it. I'm guessing any time after you execute the command buffer

grave vortex
quartz stratus
#

CRTs are a bit of a nightmare tbh, double buffered CustomRenderTextures only got WebGL support like 6 months ago. Best of luck ๐Ÿ’ช

grave vortex
#

how do I define a custom LightMode tag in shadergraph?

sly grove
undone coral
grave vortex
bronze geyser
#

What I wish to achieve is a "movement" distance outline similar to that of XCOM. Currently I have a bunch of individual planes to represent each "tile". I imagine the way this would be most easily done:

  1. Grouping all the tiles within range.
  2. Filtering out all non-edge tiles.
  3. Then using the edges of the edge tile's meshes to get a series of points with which to procedurally generate a plane that would represent.
  4. Applying a transparent material with a border shader.

I'm primarily concerned about the opaqueness of step 3 since I don't have a lot of 3D visual programming skills. I was wondering if anyone was aware of any resources that cover similar procedural mesh generation techniques?

bronze geyser
#

I guess related to this, when constructing a mesh. Aside from minor performance hits, can I just ignore some vertices? One approach that comes to mind is to simply create a bunch of vertices to represent a rectangle that would be the max height/length of the movement area, and then simply render each moveable square with 2 triangles and just ignoring any vertices that are not on a corner of a valid tile.

maiden turtle
#

you can create a new asset and add the mesh to it

plucky laurel
#

technically they can

#

you just need to serialize it with callbacks

plucky laurel
#

command buffer at most

#

maybe, im not sure, some of those corners on the screenshot look sophisticated

bronze geyser
novel plinth
#

see the one with hull method....

#

oh wait, misread, that's not related to yours I think.. scratch that!

spring gorge
#

there is anyway to setting this by code?

mortal orchid
unborn lava
#

When changing the gameobject name via code "go.name = 'something'" I don't see it changing in the Hierarchy when the game run

analog spruce
#

hey im making a sort of prop hunt game and i was wondering how i could make a script that automatically goes on top of the floor instead of floating in air or in ground? sorry if im unclear

sly grove
#

Or your code isn't running

brave viper
#

Not at all, they are used a lot

flat marsh
#

not at all, if anything using MB for literally everything is a code smell

tender light
#

Agreed.
Interfaces have issues in Unity and Abstract classes are preferred where possible for MB.
But when writing any kind of code you should stop and think if it needs to be a MB at all.

#

You can do a LOT with [SerializeReference]

jolly token
#

If you don't try to mix them and use MB only for views (and don't use SO) then you won't have problem

#

I work on gameplay on days and work on library at night

tender light
#

Well if you want them to be a SO then use abstract classes with <generics> you can accomplish a lot. ๐Ÿค” @regal olive Would that not be good enough for your use case?

#

I think I don't quite get the issue. I am sorry.
It this just not liking that the inspector does not allow you to reference a SO by an interface? @regal olive

#

You can write your own editor script. Maybe use Odin for that (I think the functionality is there but not 100% sure)
You can also perform checks for interfaces in "OnValidate". I think you can even create your own generic class and your own mono behavior base that checks all of its fields via reflection and runs their "OnValidate" method maybe. But these are workaourds upon workarounds ๐Ÿค” I am just brainstorming atm...

#

Sure ๐Ÿ‘ tho its not [ReferenceField] but [SerializeField] ๐Ÿ˜›

#

Yeah. As I said. Unity pushes you towards abstract classes. They work much better in the inspector in general

#

Sure it does. Again. Push your code into an abstract base class and it will work in the inspector.

#

Unity prefers very flat class structure for most things. Each component should do 1 thing and 1 thing only. Therefore there should be no need to have interfaces on components.
That does not mean you don't use interfaces in Unity. You do. But for non-MB non-SO scripts. You can use interfaces for [SerializeReference] Lists for example (I love this use case. You can easily create a list of conditions and checks that build up into something like a quest/achievement system)

brisk pasture
#

though you can still GetComponent by interface type, which is rather helpful for things like raycasts, and taking a action on the hit object

undone coral
brisk pasture
#

think its because i also do server side stuff and work with Go, but composition and interfaces are my default way to handling most things over more OOP style stuff

#

really the most annoying part, is not being able to drag in UnityEngine.Object based stuff, on a SerilizedField

#

otherwise it works decent

#

though the gopher in wishes i had implicit interface implementation

#

for non UnityEngine.Object based stuff it works great, or if you call GetComponent yourself

#

like most of my state machines, are regular C# objects, saved with SerilizeReference

#

and all by interface type

undone coral
# wintry wind Hi I have a script that generates a mesh and assigns that mesh to a property. Wh...

Do I NEED to do an editor script?
the simplest thing to do is to declare a context menu function using [ContextMenu] on your monobehaviour, then click the triple dots icon in the upper right corner of the component's title in the inspector to run the function you annotated with it

#if UNITY_EDITOR
using UnityEditor;
#endif
class MyScript : MonoBehaviour {
 public Mesh myMesh;
 [ContextMenu("Generate and Save Mesh")]
 public void GenerateAndSaveMesh() {
#if UNITY_EDITOR
  var mesh = GenerateMesh();
  var asset = AssetDatabase...
  myMesh = asset;
  ...
  MarkDirty()...
#endif
 }
}
brisk pasture
#

yeah can be worked around, issue is for example the faking it with a abstract class, is you can only extend from 1

#

so kinda interface like, but it pushes you into larger interfaces instead of lots of small tiny 1 or 2 function ones

tender light
tender light
wintry wind
brisk pasture
undone coral
#

you can definitely save a unity mesh as a .asset asset

#

that is the editor-native mesh representation

tender light
#

To clarify. We are talking about MBs so more than one base class is present for sure.
I am NOT talking about aggregating multiple interfaces into a single base class. And then just saying "f it" and not implementing some of the interfaces methods in the subclasses. (Who would even do that. Creating 0 side effects methods for everything? or throwing exceptions. Thats terrible architecture)

undone coral
#

i think what you found online is wrong

tender light
#

Different class for AWeaponEffect ADebuff AUpgrade etc...

undone coral
#

it does indeed have vertex and index buffers in it

#

when i see interfaces in a unity game i see "junior programmer"

#

you control 100% of the source code in a typical unity game. if you need functionality X in place Y, you can declare it there.

#

when you author libraries that will be open source, it also makes less sense to create apis that accept interface arguments

#

exhibit A: cinemachine

#

the IVirtualCamera interface is implemented by only two classes, and its purpose is to work around the fact that you cannot new an MonoBehaviour but would like to mock the behavior of one, from the point of view of how it implements blending, in a very specific corner case in their implementation

#

interfaces make sense when you cannot possibly know all the types ahead of time

#

in unity, for the most part, you know the types ahead of time

#

UGUI / EventSystem's use of interfaces is pretty flawed

#

you look at the Unity API, only EventSystem does interfaces

#

there's IJob

dapper cave
#

is there an attribute to prevent auto API update?

undone coral
#

which is really "a function signature"

undone coral
#

for example EventSystem makes you do something like "you must implement IBeginDragHandler in order to use IDragHandler"

#

UIElements, as far as i can tell, is just "the DOM"

#

which of course makes more sense

#

what should Unity have done instead? i suppose author a single UIBehaviour class (which exists by the way) with the one property public EventContext eventContext

#

eventContext.onPointerClicked += ...

#

eventContext.Cancel()

#

etc. etc.

#

EventContext.From(this).onPointerClicked += ...

#

no interfaces.

#

i can see how if you're a junior programmer and you like to plan out your thing using interfaces - i don't know why you wouldn't just make an empty class instead, but there is something in the education of this stuff that doesn't illuminate that strategy

#

i've seen it with my undergraduates

#

and it's fine. i tell them in their editor to just click "inline interface" and it's all better

gaunt spoke
#

I didn't read everything but are you saying we should never use interfaces in Unity ?

undone coral
#

i am not opposed to "thinking by using interfaces"

#

which is why people actually use them

#

but you should try to remove them once you are "done thinking"

#

if that makes sense

#

you can also think using "a class"

#

you don't have to use an interface at all.

#

there's just something in the education that sticks to intefaces

#

if you can't possibly anticipate a type ahead of time

#

then you have to use an interface

#

that is what they are actually for

#

for making libraries that have to interact with stuff whose type you cannot possibly know ahead of time

#

for many APIs, generics obsoleted interfaces

gaunt spoke
#

If I have a player that can take damage and be attacked, I find convenient to create a IDamageable and a IAttackable interface, instead of deriveing from a DamageableAndAttackable base class

jolly token
#

Though I agree as โ€œYou donโ€™t need more abstraction than you needโ€
Interface is a protocol, you wonโ€™t have same modularity and abstraction if you use class instead.

undone coral
sly grove
undone coral
#

pretty much everything in your game will be damageable and attackable.

#

or it won't

#

or, consider that such games, where you have these more complex rules, you have to do something that a junior developer is going to flop around and not do really well anyway

#

i don't think Jai has interfaces. if you really want to explore more about, what makes sense when programming games, i think jonathan blow has spent more time thinking about this than maybe anyone

ionic quartz
#

Does anyone know if there's a first derivative of Mathf.PerlinNoise()?

undone coral
#

are you trying to ask for "a texture that shows the magnitude of the slope of the point at x,y of the perlin noise texture?"

ionic quartz
undone coral
#

it really depends how their perlin noise is implemented to get a perfect answer

sly grove
#

that gives you the slope between the samples

ionic quartz
#

Not a texture, I'm going to try adding a second layer of perlin noise on top which has a greater range based on the gradient

sly grove
#

you can do this for both/all of the neighboring samples for a given sample and average them to get the slope "at" that sample point

undone coral
#

well i might as well give you the "betetr" thing

#

what i wrote isn't really true

#

because you said derivative but you really mean something else

#

you're showing me a line, and Mathf.PerlinNoise is f(x,y)

ionic quartz
undone coral
#

which is more or less prateorblue's answer

ionic quartz
#

I see, that makes sense

undone coral
#

it really depends how right of an answer you need. it doesn't sound like you do

#

weren't you trying to make a cave path?

#

you're trying to find "turns" in your path?

#

i would do so iteratively

ionic quartz
#

Yea I'll show you what I'm hoping for

undone coral
#

in my experience it's easiest when you try to do this "only looking forward"

ionic quartz
#

The darker line is perlin noise, the lighter line is a second layer of noise added where the range is greater for higher gradients:

west latch
#

hey is there an stl in unity like deque in c++

#

?

ionic quartz
undone coral
#

so you can do

f(t) = g(t)

f(t) = g(t) + f(t-1)

f(t) = g(t) + f(t-1) + f(t-2) + ... + f(0)

undone coral
#

hmm it looks like you're really asking how to layer noise

#
float NoiseWithFrequency(float x, float freq=1f) => Mathf.PerlinNoise(x * freq, 0f);
#

@ionic quartz does that make sense?

ionic quartz
#

Would that be for the 2nd perlin noise?

undone coral
#

hmm

#

i'm doing what you did

#

which is setting y to zero

#

do you see how "frequency" just means taking the argument to the noise function and multiplying it with frequency?

ionic quartz
#

I see what thats doing

#

But would frequency be my (probably clamped) gradient?

undone coral
#

you might want to add an offset so that it doesn't look like the line squished

#

hmm

#

no

#

it would just be

#

2f.

ionic quartz
#

That's just 1 layer of noise right?

undone coral
#

do you see what's going on here?

ionic quartz
#

I'm not sure I see what your seeing xd

undone coral
#

okay

#

well it' sokay

#

let me ask you this - what is the derivative of cos?

ionic quartz
#

Sin?

undone coral
#

okay

#

would you say perlin noise looks periodic?

#

so if you want something periodic with a known derivative, that's one of your options

#

another derivative of cos(x) is cos(x+2pi)

#

(-1)^x is also periodic

#

and weirdly neglected

ionic quartz
#

Why would I need something periodic?

undone coral
#

perlin noise is fast that's why people like it

undone coral
#

"rescaled and added onto itself"

#

that's what i was trying to illustrate for you

#

these are f(t) = g(t) methods, "no looking into the past" methods

#

maybe for cave it'll be easier for you to do, "i look into the past" methods

#

you can transform many look into the past methods into no looking into the past methods

obsidian glade
undone coral
#

^"biased random walk"

#

@ionic quartz to me this looks a lot like a cave

#

but here's the thing, we can hand you this stuff

#

or you have to like, slog through a lot of math and learn the names for these things

#

that's 90% of the problem

#

so if i had to make a cave, i would probably do "10,000 biased random walks across a grid. i keep all grid points that were visited N ~ 1,000 times or more, and all closed loops that were visited M ~ 100 times or more"

#

or maybe the amount of grid point i keep is based on some other factor

#

it's an art

ionic quartz
#

I'm understanding bits of what you are saying now but not lots

undone coral
#

yeah

#

i mean you'll google biased random walk

#

and it kind of look slike a cave

#

that's what matters ๐Ÿ™‚

#

i think there is stuff like "function zoo"

#

where you can just look at a graph of tons of stuff

#

and fish around for something that looks like what you want

ionic quartz
#

Oh that's cool

undone coral
#

i don't know what it'll be called though

ionic quartz
undone coral
#

maybe you should make one ๐Ÿ™‚

ionic quartz
#

I love the motivation for more resources but I'm not sure I have the passion for something like that xd

undone coral
#

yeah i know

#

it's okay

#

anyway this is a fun journey

ionic quartz
#

Prehaps by the time my uni dissertation comes around I'll feel differently about functions lol

torn basalt
# undone coral yeah i know

Hey, I ended up with everything working out really well but I have one more question about vert manipulation. Even after updating the bounds and reassigning the shared mesh, the scale of the mesh doesn't update. I tried using the bounds extents size but that was inaccurate. Is there a way to update the scale after manipulating the verts.

#

?

torn basalt
#

I tied some subtle haptics to the dragging of the verts. Its trigged by changes to the scale of the mesh. I guess I could cycle through the verts being dragged and tie it to the position changes. But if someone has a shaky hand it would constantly call it

#

sorry just type thinking.

undone coral
#

this is part of the procgen journey

stable moat
#

Hey guys, i have a problem with Bossfight, if someone can help us i would invite you in our discord server (we are 4 people) and can share the screen. would be nice ty ๐Ÿ˜„

chilly nymph
#

Is there a good way to convert a http request for a .wav into an audio source?

chilly nymph
#

Thank you ๐Ÿ˜“ I should have just googled it...

shy spruce
#

Is there any easy way to establish whether a collider is entirely inside of another collider? ie no intersection with the outer colliders perimeter? Or something I have to write myself?

regal lava
#

Could just check for positional values when they collide and clamp a range for what you'd would consider full inside of it.

shy spruce
#

Interesting. It gets weird though with square colliders (box 2d) near the corners I think...