#archived-code-advanced

1 messages · Page 200 of 1

compact ingot
#

try calling the fields "Item1" and "Item2"

glacial wedge
#

Instead of 0 and 1?

compact ingot
#

yes

#

the deserializer will use properties on the target type, not the indexer, is my guess

glacial wedge
#

it works....

#

but I have 0 and 1 and can't change the input

compact ingot
#

nice, does it also work with string integers?

glacial wedge
#

it works both as integer and strings

glacial wedge
#

so I should extend JsonConverter<Tuple<int, int[]>>?

compact ingot
glacial wedge
#

mmm. interesting

#

It works!! great thanks Anikki

rich charm
#

Good day everyone

#

We really need help with our ANM neural network and fixing some problems with our unity game

#

Very basic stuff, wondering if anyone can hop onto a call and help me out?

undone coral
undone coral
#

are there any benchmarks showing performance impact relative to garbage per frame?

undone coral
#

i guess the profiler says how much time is spent

glacial wedge
#

How to unexpose ExposedReference by code?

supple crest
#

Are bit fields bugged out of their mind or something? I don't understand what the Unity inspector is doing here:

[System.Flags]
public enum LookupKey
{
    Nothing = 0,
    Test1 = 1 >> 0,
    Test2 = 1 >> 1,
    Test3 = 1 >> 2,
    Test4 = 1 >> 3,
    Test5 = 1 >> 4
}

[System.Serializable]
public struct LookupValue
{
    public LookupKey Key;
    public float Value;
}
#

Ahh, seems it might not like the bit shifting? Setting the values like so seems to have fixed it, unless there's some error in how I constructed my bit field:

[System.Flags]
public enum LookupKey
{
    Nothing = 0,
    Test1 = 1,
    Test2 = 2,
    Test3 = 4,
    Test4 = 8,
    Test5 = 16
}
glacial wedge
#

You failed the shift side, you should move left, not move right the single bit

#

replace >> with <<

rich charm
#

We hard coded our AI

#

Good evening guys, we are having a problem where our AI and our player are moving at the same time sequentially and we need them to move individually. Does anyone have a clue how to fix this?

#

That's the issue we are currently having

supple crest
true grotto
#

Hi, when I set time parameter in the alpha of a Gradient it gets rounded to only 1 decimal.. any fix to this? I need like 4 or 5 decimals

undone coral
#

is there a way in event system to send clicks to all objects for the current raycast, regardless of blocking?

#

should i override input module

#

and use .use?

undone coral
#

as is

#

the way it should work is .used should default to true, and if i sent it to false (i.e., "preventDefault") the input module should propagate. is this how it works?

warped forge
plucky hound
#

The exact location of the data in resulting list for the specific articulation body can be found by calling ArticulationBody.GetDofStartIndices and indexing returned dofStartIndices list by the particular body index via ArticulationBody.index.
Huh?

undone coral
#

you can grep.app invocations of it to see examples

warped forge
# undone coral what's your objective?

Inspired use case? Drawing orthographic overlays, basically identical to canvas really. And then of course just using them for general purposes.

Really not obvious things in the documentation being clearing or modifying command buffers after they've been added to the camera.

lethal sparrow
#

i do not undesand this channel at all

undone coral
#

and then it makes more sense

#

based on what you're describing, is most of the drawing work done in CPU?

#

it sounds like the only command you really need then is to blit

#

if it's the opposite - if the point is to do fully GPU drawing... i think you'll still want to blit?

silver schooner
#

How can I tell if an object has been culled by Umbra?

IsVisible() won't work, because it always returns true for objects which cast shadows. But I don't mind shadows occasionally popping out of existence when an object is no longer rendered if it means a massive improvement in framerate.

warped forge
warped forge
silver schooner
#

Also, ideally I'd like to set my objects to be inactive when they're no longer visible, so all the dynamic shadows, Rascal dynamic skinned mesh colliders, and dynamic bones on my avatars are disabled when they can't be seen, but I imagine if I do that the first time the object isn't rendered, it can never become visible again. So I'm wondering if anyone has a solution for that, besides recursively going through the whole hierarchy and disabling or enabling the scripts one by one.

The only thing I can think of is to have a cube with an invisible shader on it which the culling system would think is supposed to be rendered, and then have the actual avatar be a child of that, so I can then use the visibility state of that cube to decide if it should be rendered or not. But this also seems unreasonably complicated. Also I'm not sure if dynamic shadows on children would cause the cube to always be considered to be visible, so that's a concern too I guess.

undone coral
#

the HDRP source code is the best reference

#

because it uses the most features

#

from that API

polar cove
#

Have no idea if you guys can help but my project randomly just stopped working

#
0x00007FF65F1501E5 (Unity) AssetDatabase::InitializeAssetDatabase
0x00007FF65EA0A91F (Unity) Application::InitializeProject
0x00007FF65EE63E78 (Unity) WinMain
0x00007FF66018582E (Unity) __scrt_common_main_seh
0x00007FFAA0367034 (KERNEL32) BaseThreadInitThunk
0x00007FFAA0682651 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========```
#

this is the log output

polar cove
#

The reliability of unity makes me want to rotate my head 180 degrees.

errant plinth
#

Does an earlier work?

polar cove
#

yes, I cloned my github repo and rebuilt any setting files

#

it's sad that I know how to rebuild project files so well... i've done it so many times and it's discouraging to happen on my first plan to release project.

#

got my project back up and running after fixing some file naming inconsistencies.

somber swift
hallow cove
#

ok so, I'm trynna do something pretty advanced, and I don't know how I would go about this

#

but essentially

#

I'm trying to make a node script editor, that people can download and use to make maps for my game

#

kind of like vrchat's UDON

#

I see Bolt has a good system in place, but I have no idea how I would replicate that

unkempt nova
#

Think there's something called NGP, a node graph library that'll let you make stuff like shadergraph

#

Can't seen to find it though

#

@hallow cove

hallow cove
#

I know how to make a graph editor, I just don't know how I should organize the search window

#

and handle the connections between nodes because of that

#

I'm thinking of just copying this from Bolt

hallow cove
unkempt nova
#

Ok

hallow cove
#

I already made my own graph editor, with a compiler to C#, it's just the search window that I don't know how to organize

#

maybe looking at the source code for Bolt will help

unkempt nova
#

I figure you had a bunch of node types, just organize them that way like bolt does. I think UITK has an element for this view

sage radish
#

Bolt and NGP use AdvancedDropdown for their node menus. It's a built-in editor type that is also used for the Add Component menu.

hallow cove
#

I mean more like, how I would get stuff like all UnityEngine functions like so

#

what I get back is usually completely unrelated

sage radish
#

Oh. Why didn't you say so the first time you asked? Your initial question doesn't even mention a search menu.

unkempt nova
#

Feels like you're asking about Unity's TypeCache

hallow cove
#

yeah it's a little complicated, the real reason I'm asking is because I don't know how I should go about this

#

this is a tool to make maps for my game, so it doesn't need stuff that's "malicious" or that collects data, just classes like GameObject, the components on them and some custom events

sage radish
#

Either you list everything that can be found with Reflection, or you hand pick what to show in that list.

hallow cove
#

I guess my best bet is to copy bolt in my own system

#

and just, hand pick what I want

#

and then figure out how I would handle connections between nodes

#

seems I'm on the right track

buoyant nacelle
#

I am trying to do a stats system for my MOBA game. The stats system is similar to League of Legends. There are various stats (health, mana, attack damage, movement speed, etc). Every character has default stats, which progress with level. Then, these stats can be modified through items, spells, etc. Some characters might have mana, while others do not. I am struggling to come up with an effective way to manage it.

My initial prototype:

SO - statDefinition, which has base value and capacity of the stat
SO - statDatabase, which has a list of all stats
C# Class - Stat, which handles adding modifications
MB - StatController, which has a reference to StatDatabase

hallow cove
#

however, getting the methods for a type (GameObject in this case) returns these getters and setters

#

I can't find set_active and the rest in the source code so

#

???

fresh salmon
#

It's a setter method of a property, it appears like that when you .ToString them

#

Same for get_*

hallow cove
#

how can I not display them?

fresh salmon
#

Depends on how you're getting that list

#

You can filter them out by passing BindingFlags enum values

hallow cove
#

oh yeah right

#

yeah I can't figure it out

lost shoal
#

Hello guys, I have a little problem. I'm implementing state machine to my game and I am using Zenject Framework. I want to Inject class objects in states to operates on them but when I am trying that the object is null. Like State dosen't see the Container but see the Zenject with field Inject. Pls help.

undone coral
#

is there a definitive implementation of converting a PointerEventData position to a rect transform position / localPosition / anchoredPosition ?

#

that correctly takes into account canvas scaling and whether the canvas is screen space / world space / camera space (most do not)

#

i have seen and authored this a million times

#

i don't remembe rit

plucky hound
#

I build a dog prefab with ArticulationBody, standing up legs straight . I add the prefab to my scene and pose it lying down. when i run the jointPosition reported is still zero. What gives?

sour veldt
#

Hey! I'm making an enemy that moves between 2 spots along a curve (of bézier). My enemy moves correctly from point 1 to point 2, but I'm not sure how to move him back to point 1 and then continuously restart that process. Here is my code:

`void Update()
{
//transform.parent.GetChild(1).transform.position = transform.position; //trigger moves along

    if (count < 2.0f) 
    {
        count += .8f * Time.deltaTime;

        Vector3 m1 = Vector3.Lerp(pathPositions[0].position, pathPositions[1].position, count);
        Vector3 m2 = Vector3.Lerp(pathPositions[1].position, pathPositions[2].position, count);
        transform.position = Vector3.Lerp(m1, m2, count);
    }
}

`

What can I add or change to the code so I can make it move back to point 1?

gray pulsar
sour veldt
#

Thanks, I've tried that but it makes the enemy take on a whole other position

#

Thanks I'll give it a try

weary gust
#

I'm attempting to make a "debris layer" sprite for a 2D top down game, I've looked at creating a transparent Texture2D and then using Graphics.Blit to render the Texture2D objects from the debris sprites.

#

Then using Sprite.Create to build the sprite from the resulting Texture2D

#

Are there any other methods of doing the same thing?

#

The goal is to remove the need to have thousands of debris sprites in the scene

weary gust
#

Not sure how I missed Graphics.CopyTexture() the first time I looked at the docs, but that's exactly what I was looking for.

languid sinew
#

Getting errors due to float values

#

I'm using a vector 2 as the dictionary key

#

and I can't access the entries because it says they're not in there, when I know they are

#

I think it's like 0.00000001 different or something

#

Any suggestions for storing two integers as the dictionary key?

sage radish
#

Vector2Int

languid sinew
buoyant vine
#

tuples

woven kettle
#

hey guys, I wanna ask experts about something.

I have a list of object "Impacts" , this Impact object has references to the prefabs that appears on impact
ofc impact would be used more frequently and in masses ( 100-1000s times per match)

I have 3 options of where to store that list that I would frequently use.

1- on the weapon itself ( a little hard to maintain)
2- on every wall or prop object in the scene ( many instances of the same script )
3 - on a manger with a static instance of itself so I can access it all the time ( it will be call the whole time as I explained )

Is any of those methods has a performance consequence ? If yes, which one has the least or if there is a better option ?

humble leaf
hollow garden
#

Yeah, i'd use an object pool

woven kettle
#

@humble leaf @hollow garden thank you so much 🙂

languid sinew
#

Would it be possible to generate a link to my itch.io game that will run the webgl browser game with a variable?

Ex:

mypage.itch.io/mygame/123456

-> launch webgl build, and set myVar to 123456

#

I’m making a tool that allows you to make a deck for a game I play, and I’d like people to be able to share links with eachother that takes them to the deck that person made

languid sinew
green ether
#

Scenario:
My player drops bombs with a script. These bomb are instantiated right on top of the player position. Because of this, my player collides with them when they are spawned.

Question:
How do I make it so when my player or any other player has a bomb spawned on top of their position collision is off between them, but as soon as the player is no longer colliding with the bomb collision between the two objects is renabled so they can't walk through it?

I would like to know how to handle this as I believe it would help in a scenario the player clips inside of anything by accident, they can just walk out of it and collision is renabled.

bold slate
#

From what you describe you can instantiate the bomb where it's collider will use IsTrigger. Then when the player leaves the trigger area of the bomb, turn the IsTrigger off so it uses normal physics colliders.

hushed fable
bold slate
#

Would this be as simple as just parenting the ball to an empty game object that is positioned in the middle of the tube?

I wonder if that would work.

green ether
bold slate
#

Cool. Yeah, sometimes you don't need the complete solution given to you, just a nudge in a different direction helps 🙂

hushed fable
green ether
hushed fable
undone coral
#

looks cool

clever pond
#

Hey people, I need help with implementing an authentication system to unity for the IOS game center, most websites either redirect you to a monetized asset on the asset store or to an obsolite/depricated method, can anyone redirect me to a proper simple tutorial/document to help me with the said task ?

I implemented the following for Google Play Store using the gpgameservices package a while back, something similar to that really helps.

thank you in advance.

tidal relic
#

I want to create a property field in my editor class for UnityEvents

public class CutsceneCollider : MonoBehaviour
{
    public Dictionary<int, UnityEvent> generalActionDictionary = new Dictionary<int, UnityEvent>();
}

I have this dictionary and depending on the key, I want to display the property field of that event here in my editor.

public class CutsceneColliderEditor : Editor
{
   public override void OnInspectorGUI()
      {
          cutsceneCollider = (CutsceneCollider)target;
          generalActionDictionary = cutsceneCollider.generalActionDictionary;
          if (generalActionDictionary.TryGetValue(KEY, out UnityEvent VALUE))
          {
              EditorGUILayout.PropertyField(VALUE);
          }
      }

How can I turn my "VALUE" into a property?
I need to somehow get the serialized property of a variable in my class by using the reference of that variable and not the name
And I don't know if that is possible or if syntax exists for that

flint geyser
#

what are the exact benefits of plain C# classes over MonoBehaviours?

#

it is often required to use as least MBs as possible in vacancies

novel plinth
#

when you don't need the execution order of monobehavior (start, awake, lots others..)... when you don't want to attach it as a component.. when you want to instantiate where ever you want .. lots others

flint geyser
#

Well, I wasn't asking which and when to prefer but rather why do companies want people to use as least MBs as possible, perhaps there are some benefits?

novel plinth
flint geyser
#

Also the vacancies I'm talking about are mostly for a jun mobiles developer

undone coral
hallow cove
#

ok so I have this type = (Type)SearchTreeEntry.userData;

#

however the userData is an object which is why I'm casting it

#

and it can be more than just a Type

#

so in order to check what it is, I made a variable array like this:

#
    {
        "type:",
        "method:",
        "field:",
        "property:",
        "parameter:",
    };```
#

and when I assign the userData I add a "type:" at the start for instance

#

however, I don't know how to cast using a variable

novel plinth
#

pretty sure you asked this already, and somebody answered you. Either way, you must cast it to a known type on runtime from another variable

    someType = typeof(int);
    var someOtherThing = Convert.ChangeType(somethingTo, someType);
hallow cove
#

yeah but that was before I realized the types weren't just Type, and the variable could be more

novel plinth
#

bcos what you're looking for is to cast from unknown type and hoping to automatically do it for you.. so .. uh

hallow cove
#

yeah

umbral trail
#

How do I go about reporting a unity editor crash when it doesn't output anything to the crashes folder?

novel plinth
hallow cove
#

the userData is some built in function of type object that unity provides

novel plinth
#

ye ye... it's VisualElement.userData isn't it...

hallow cove
#

SearchTreeEntry.userData

novel plinth
#

ye ye.. that's a uitoolkit right?

#

if so then yeah

undone coral
hallow cove
#

my brain is tired and doesn't understand that so I'll just re-explain:
I have a method for populating a search window, and another for when I select something. I can assign a userData to each element in the search window, and then retrieve it when I select and element

#

and userData is an object

#

here I assign it to a various amount of types

undone coral
#

okay

#

this all looks fine

#

right now userData is always a string

hallow cove
#

yes

#

I want to check using the strings I added before the actual variable

#

so I can get what type of value it is

#

and then cast it as that

undone coral
#

check what?

#

userData is always a string

#

there's nothing to cast here

#

what do you want to cast?

hallow cove
#

behaviourView.CreateNode(type, name, behaviourView.GetLocalMousePosition(context.screenMousePosition));

#

the type you see there is what I need

#

idk how to word this

#

I need to see what userData is

#

either a type, methodinfo etc.

undone coral
#

userData is always a string

#

why not do

hallow cove
#

it's a string

#

but my CreateNode function takes in a type

undone coral
#
class SearchTreeEntry {
 Type searchTreeEntryType;
}
hallow cove
undone coral
#

then new SearchTreeEntry() { searchTreeEntryType = typeof(MethodInfo) }

hallow cove
#

yes

undone coral
#

does search tree entry need to be something like JSON?

hallow cove
#

but I need to tell the function if it is a methodinfo or a type

#

so I can cast it as such

#

otherwise it returns null

undone coral
#

doesn't it?

hallow cove
#

apparently not

undone coral
#

you're using the word type

hallow cove
#

Type and MethodInfo are different

undone coral
#

yes, that's true

#

they are

#

hmm

hallow cove
#

I can't cast MethodInfo as a type

#

the thing is, this might be a good thing

#

I could just give the string

undone coral
#

you can switch a string.

hallow cove
#

cause I need different logic based on if it's a type or a method or a field etc.

#

yeah

undone coral
#

well you are saying type

hallow cove
#

yeah I know

#

excuse me I just went outside and I'm introverted, my energy is 0 rn

#

I guess I'll just update the CreateNode to take in a string and then do logic based on that

twin vector
#

i still don't understand what you're trying to do, if you want the type from the method info you can do methodInfo.DeclaringType

hallow cove
#

yeah I can't really explain it

undone coral
#

it's okay

#

you are trying to do exactly what i wrote

#

which is the function Type GetTypeWithName(string name)

#

@hallow cove indeed, the best way to express yourself is to write a function signature that solves your problem

hallow cove
#

one issue tho

violet field
hallow cove
#

@undone coral can we quickly talk in dms?

#

so we don't disrupt the main chat

undone coral
hallow cove
#

so, I need to get the class a method or field or property is in

#

and then the method / field / property itself

undone coral
hallow cove
#

cause I need to display where the function GetComponent is from

#

the GameObject class

#

I guess the best way is to add that to the userData as well, and split the userData string into 3 parts

#

by detecting spaces

undone coral
undone coral
hallow cove
#

uhhhhhh

#

it's an object

undone coral
#

okay nevermind

hallow cove
#

and I thought using a string is the best way to have it be universal

undone coral
#

let's look at the code i wrote

#

is this what you need?

hallow cove
#

yeah please explain my brain smooth

undone coral
#

you need an implementation of LookupReflectionInfo

#

?

hallow cove
#

I mean I do not understand what that is supposed to be

undone coral
#

okay

undone coral
#

why don't you write

#

a function signature

#

where what the function returns is what you need

#

try to express in code what you need

#

don't even worry about the arguments for now

violet field
hallow cove
undone coral
#

i mean you've gotten quite far

#

maybe you are very, very tired

hallow cove
#

lmfao

#

I am

undone coral
#

i am asking for something very simple

#

and you haven't given it to me

hallow cove
#

I do not know what you mean

#

that's the issue

undone coral
#

and you're talking about an array of strings, which is inconceivable to me how that solves your problem

#

hmm

#

you definitely know what it means to "write a function signature"

#

that means

#

fill in the blanks for

#
public __YOU_NAME_THE_TYPE__ __MY_FUNCTION_NAME__(__ARGUMENTS__ __ARGUMENT_NAMES__);
#

i am asking you to write

#
Blah MyFunction(SomeArg args);
#

okay, but make decisions about what blah and some arg are

#

IN ORDER TO EXPRESS

hallow cove
#

there's something I haven't mentioned yet

undone coral
#

what it is you need

#

lol

hallow cove
#

so, I need to first check if it is a method, field or property
if yes then I need to display what class they are taken from

#

this is an example from vrchat's sdk

undone coral
#

i inferred that you want to turn a search tree entry into a propertyinfo, methodinfo, or fieldinfo instance, plus a reference to the type that contained that instance

#

which seems so utterly straightforward

#

that i am wondering what i am missing

#

so i am asking you to write the function signature, which is how you would epxress what you need, in code world

#

you are inhabiting code world

#

you have to write code

#

i think you saw OneOf<> and had a heart attack

#

but hey, this is code world. you should learn what OneOf<> is / means

#

because it is the solution to your problem

#

at least, what i am hearing so far

#

you haven't expressed in code what it is you need yet

#

you still haven't given it to me

#

very concerning

hallow cove
#

I don't know how to express it through code

undone coral
#

i'm not asking you to solve the problem

#

i'm asking you to define hwat you need

#

which is... a type

#

it's declaring

class WhatINeed {
 int anInt;
 string aString;
}
#

do you see what i mean?

#

tell me what you need

#

fill in the class with the fields you need

#

not searchtreeentry, not userdata

#

tell me what you want at the end

hallow cove
#

it depends, I need to see if it's a method, field or property

undone coral
#

lol

#

jesus christ

#

okay

hallow cove
#

if it is then I also need the type they derive from

#

if not then I just need the type directly

undone coral
#
struct WhatReimuNeeds {
 Type containingClass;
 // only one of the next three fields is set
 MethodInfo methodInfo0;
 FieldInfo fieldInfo1;
 PropertyInfo propertyInfo2;
 int ifThisIS0ItsAMethodInfoIfits1ITsAFieldInfoIfIts2ITsAPropertyInfo;
}
#

is this what you need?

hallow cove
#

oh

#

yes-

undone coral
#

lol

hallow cove
#

😭

#

agony

undone coral
#

why was this so challenging to express?

#

you've been doing this for a while

hallow cove
#

I don't know honestly

undone coral
#

you're getting caught up in your own bullshit

hallow cove
#

I struggle with communication that's all you need to know

undone coral
#

lol

#

well it's better to just write in code

#

but if i send you something

#

like OneOf

#

you have to look it up!

#

you have been struggling with OneOf

twin vector
undone coral
#

you didn't know OneOf as a programming idea existed until now

#
class WhatReimuNeeds {
 OneOf<Type, MethodInfo, FieldInfo, PropertyInfo> searchResult;
}
#

you can EASILY implement OneOf informally. it's just whatever field isn't null.

hallow cove
#

yeah

undone coral
#

you can download OneOf from github

hallow cove
#

I know

#

I looked it up

undone coral
#

cool

hallow cove
#

but I had to answer and I paused it 😭

undone coral
#

now your powers have enhanced 🙂

#

it's okay

#

do you NEED OneOf? usually OneOf is a code smell

#

it really depends what you're trying to do that is common between these four things in your oneof

hallow cove
#

I won't add it to my project cause I can just do 2 if statements or something to get the logic I need

undone coral
#

it is usually better to model it differently - for example

interface WhatReimuActuallyNeeds {
 string name;
 SlotDefinition[] slots;
}
interface SlotDefinition {
 DirectionEnum direction;
 bool acceptsInt1;
 bool acceptsInt2;
 bool acceptsInt3;
 bool acceptsFloat1;
 ...
 bool acceptsString;
 bool outputsInt1;
 ...
}
WhatReimuActuallyNeeds ConvertObjectToNodeRepresentation(object target);
twin vector
#

i doubt Udon (the framework you use for the node stuff) would allow the use of reflection in production, iirc they're pretty strict on what they allow and disallow, idk if the plan is to visualize all MemberInfo or to use them to build stuff

hallow cove
#

no, I am trying to recreate Udon

#

at this point I could just slap Bolt into the project and call it a day

#

but I've been working on this graph editor for months sooo

twin vector
#

if its your own recreation, technically nothing stops you then from 'graphifying' C# things such as Fields, Props and MethodInfos

#

(Might be hell on performance though)

#

Delegates are a thing though do take up some memory so its a balance of memory vs speed

hallow cove
#

it's not done, obviously, since I'm still trying to figure out how to create different nodes based on methodinfos and all that

woven kettle
#

Hey,

I wanna add an air duct on both sides of the wall by a raycast
so lets say " I ran the raycast function and it hit a wall "

public Transform s;
public GameObject duct;
RaycastHit hit;
if( (Physics.Raycast(s.position, s.forward, out hit, 10))
{
  // add duct
  GameObjcet item = Instantiate(duct);
}

how do I make sure that the item is going through the wall with its center in the middle ( knowing that the wall thickness is 10 ) ?

hit.point ( gets the point )
hit.normal ( gets the surface ) , anything for the center of the object ?

undone coral
#

Udon was a Mistake

hallow cove
#

why is that?

undone coral
#

they could have started Roblox Studio once

#

and learned everything they needed about doing that sort of thing

#

you write your game state machine in lua, and network diffs of the lua memory arena around

hallow cove
#

didn't vrchat make that just for scripting maps tho-

undone coral
#

they are trying to use it to solve general purpose replication

#

if you need to special purpose replication of a particular thing, like a transform, you declare it specially in lua. that's it.

#

i would also sooner use Blockly/Scratch to author luna than a node based editor

#

i think the node based editors have appeal for tech artists, and tech artists belong to fandoms and therefore contribute art-asset-adjacent things like levels

hallow cove
#

I don't understand what's wrong with their approach-

undone coral
#

but if there were an exchange rate, i'd rather convert 1 programmer to contribute than 10 artists

#

and a programmer will just wanna write C# or whatever

hallow cove
#

they just made a way to script maps that's more easy to understand by the average individual that doesn't know C#

#

I don't see what the problem is-

undone coral
#

that is the problem with their approach

undone coral
#

this is mostly unity's fault

#

and the platforms

#

there's no reason you should be able to run whatever code you want in a web browser, but everything has to be signed in an app

hallow cove
#

Is it wrong if I try to make a system like that? I mean most of the things you'll use it for is just making a button toggle a gameobject and stuff

undone coral
#

if you wanted to network it, you woul dhave to deal with a bajillion problems very rigorously

#

as long as networked replication is not on the table you should be gucci

hallow cove
#

I do tho

undone coral
#

hmm

hallow cove
#

I don't know why that would be a problem

#

as I said

#

I am making a compiler to C# for this

#

so I don't see why I couldn't do that

undone coral
#

i see

hallow cove
#

my Mirror knowledge is still pretty limited

#

sadly

#

but I doubt I can't make it work with networking

misty glade
#

I'm making a multiplayer game and my intent was to use username/password, but my game designer has let me know that he doesn't want to do that because of IAP-contamination across platforms (ie, Apple/Google might want ring fenced user cohorts or put up a fuss if our product were multi-platform). I disagree, but that's why he gets the big bucks and I "just work here" 🙂

To that end, any thoughts on whether SystemInfo.deviceUniqueIdentifier is good enough (without a password)? I'd be worried that it's an insecure method to track a user - ie, someone could forge that item and "steal" someone else's character.

My original solution is to use the DUI as a starting point, but offer the user the ability to add a password to their account (giving them some sort of in-game bonus). The system would still use the auth token I currently use, so entering a password to an account with one might never actually be needed, so long as the user logs in every 2 weeks or so.

Any thoughts?

flint sage
#

Sounds like a security hole in a multi player game

#

Besides, you probably have to support apple login in ios

#

So might as well do sso

misty glade
#

Well, security hole in what sense?

#

I'm thinking that a user could optionally add a password to their account - if the user doesn't have a password, then the system just logs them in (automatically) with device ID

#

if they DO have a password then it logs them in with deviceID/password and grants them a token

fierce quiver
misty glade
#

oh for sure.. I'm not saying they can't.. I'm just wondering if there's any problems with my approach.. here's sort of what I see so far:

  1. Device IDs could be spoofed, so if a user A found another user B's device ID, and B didn't enable a password, A could simply log in as B by spoofing their ID.
  2. I couldn't ban players, since they could just spoof a new device ID. Although I suppose the same would be true of username/password.
  3. Users won't be able to migrate to a new device - if they buy a new device, all their purchases are gone without support/manual intervention ... and I'm not sure how to do that easily, aside from letting support manually set a device ID.. which brings its own problems (how do I know a user is who they say they are)
sly grove
misty glade
#

Hm, that's an idea, too, although we're going to be on steam/windows as well.. SystemInfo.deviceUniqueIdentifier works on windows too, so I was sort of hoping to build something once that would work for all 3 platforms

sly grove
misty glade
#

I suppose I can't get away from the downsides of any given approach though.. if I want users to be able to just automatically login/create accounts, then I have to tie them to the device id

#

Yeah, I mean, I have that already

sly grove
#

I mean that's... a ui that has username/password fields

misty glade
#

I'm told that Apple/Google don't like cross platform

sly grove
#

that's not a whole system

misty glade
#

Fair 🙂 but I mean, it works, I just don't have a signup workflow built

#

I have username & password authentication with tokens

sly grove
#

you'll need a backend to support that, a signup workflow, etc.. and it's easy to mess this up and do it insecurely

misty glade
#

Yeah .. the signup workflow is what I'm building now

#

I have all the backend & security in place as it is but.. requirements changed

#

encryption, salting/hashing, auth token etc

fierce quiver
hoary pendant
#

They weren't salted before?

misty glade
#

they're salted

compact ingot
#

Anyone saying they have a secure system probably doesn’t know enough to see all the holes 😉

misty glade
#

sorry, let me backup and restate the entire problem:

  • Current: Users must login with username/password. No signup workflow exists - I was building it today. System is fully cross platform.
  • New requirements: No cross platform play. Simple (automatic) signup.

My proposal is to use DeviceID in place of username, and put no password by default until a user enables it.

wooden cedar
#

It also depends on the value of the data

misty glade
#

No value, really

#

The value is probably in migrating the data - like if a user gets a new device, I can imagine them wanting to have all their purchases and progress

#

(but if I use device ID as the user key.. obviously I can't do that without manual intervention... which.. maybe that's OK?)

wooden cedar
#

Yeah thats pretty common. I usually follow a process like what PlayFab uses. Remote accounts tied to email addresses (optional), for data synchronization. But these days I think most folks just use the on-device iOS and Google Play features (if using mobile).

#

I'm curious where you end up 🙂

misty glade
#

Hm, yeah. Does unity have google play integration? Ie - can I get an email address from a user without them needing to input it?

#

We're not going with playfab - it was far too expensive in previous projects

#

like $10k/month at scale

wooden cedar
#

Oh yeah, I 100% don't recommend Playfab

#

We used nakama for a while before rolling our own in angular/mean stack

misty glade
#

I've reproduced nearly everything I think we need and our bill is likely going to be less than $200/month

#

that's our entire azure stack - cosmos DB, app server, container registry, metrics, etc

#

game server(s), admin tools, everything

#

I'm just.. really stuck on this device ID thing.. I don't like it because of the problems it has

wooden cedar
#

But their process is good to copy. You can get Playfab for free for 2 years now, but it is still not worth it imo. But we don't use azure either, we migrated everything to our own servers.

misty glade
#

Azure is kind of a pain in the dick but.. it's cheap compared to the comprehensive services (playfab) and.. once you get your head around it, it's not too bad

wooden cedar
#

Yeah, I'd probably want to pair the device ID with a token of some kind if you want to restrict device access. The device ID won't carry to a new phone anyway.

misty glade
#

that's with 500x bots running 24/7

#

OK, I'm going to pull the trigger on this approach. I'll use device ID as the uid and ... if a user upgrades their device, we'll have to figure out how to migrate the user securely (mostly concerned with "they are who they say they are")

wooden cedar
#

We pay about ~80/month, and thats for our 8 dedicated servers (48GB, i7's) with unlimited bandwidth. Great little beasties. But back in the day we used Azure and NfoServers a lot

misty glade
#

Maybe I can collect a bunch of data points in the SystemInfo space at signup .. shrug

wooden cedar
#

Anyway, I won't distract, good luck. I'd porobaly build it out the same way unless I really needed to worry about the securement

misty glade
#

what's the easiest way to get identifiable information in unity? do I have easy access to google play / ios info, or do I need libraries for both

limpid prairie
#

Guys, a data structures question.

I have a 2D array of a bunch of units.

Let's say, I will frequently need to find the closest valid unit to any of the units in this 2d array.
What sort of data structure should I use, or what method to be able to get that without bad performance?

misty glade
misty glade
#

so if I tracked some identifying information (like email address or username even) then.. they could say "I'm Sharping" and customer support could look and verify that their user was created on such-and-such a date, and had email:sharping@sharping.com or whatever

wooden cedar
#

Yeah I think for that (automatic device ID sync) you'd need to use either a cross platform plugin, or a direct Google Play Games Service or something / assuming you want to let the on-device service handle that sync for you

misty glade
#

deviceID by itself wouldn't be comprehensible by a customer support human

limpid prairie
#

And I'll be doing this very often, so I am worried about doing it the brute force way, cause it'll be many times per frame possibly.

misty glade
#

even many times per frame is probably nbd

limpid prairie
#

What or how should I write that best. Is there a known algo

misty glade
#

that kind of CPU use is pretty hard to max out compared to .. other things

#

how many items in your grid, and how big is your grid, roughly?

limpid prairie
#

It could be very big, idk that detail right now

misty glade
#

because honestly I'd just write it in the way that would be the least-buggy or least-prone to bugs, and worry about performance later

limpid prairie
#

I mean I know the brute force way is just:

        for (int x = 0; x < grid.Width; x++)
        {
            for (int y = 0; y < grid.Height; y++)
            {
                // Check distance of this (x,y) to the target point, and record shortest
            }
        }
misty glade
#

so something I'd do then is like...

class GridObject 
{
  public float GetDistanceFrom(int x, int y) {}
}
limpid prairie
#

But I just thought there'd be something way better

misty glade
#

yeah that's just what I was going to write out

limpid prairie
#

There's no way this is the best thing tho

misty glade
#

or alternatively if your grid is super sparse - keep track of only the items in the grid

hoary pendant
#

Closest pair of points algo? Pretty common

sly grove
misty glade
#

it's not the best way, but it's the simplest and probably doesn't matter for small grids/sizes

limpid prairie
#

What about a way of iterating through all the nodes in a spiral way starting from the target node itself?

misty glade
#

remember, the unasked question's answer is usually: make it the simplest and worry about performance when it becomes a problem

limpid prairie
misty glade
#

you could do that too but again, sounds complex, and is likely to be buggy on the first few attempts

limpid prairie
#

I have it working, I didn't mention this sorry

#

I just feel like this is weak code

limpid prairie
#

My operation used to be 80-100 ms, now it's down to 11ms

#

and I was seeing if I can get it even lower

limpid prairie
misty glade
#

the two simple approaches that come to mind for me are:

// one
for (int x = 0; x < width; x++) 
  for (int y = 0; y < height; y++) // get distance, track the shortest

// two
List<GridObject> allObjects;
foreach (GridObject go in allObjects) // get distance, track the shortest 
#

11ms or 11ns?

limpid prairie
#

So a different target point from which to find other shortest point

misty glade
#

11ms seems absurdly slow for one check of the entire grid - normally you could check millions of elements in 1ms

limpid prairie
#

11ms is my entire thing running 24/7

#

like my game's map doing operations

#

which im injecting repetition into

misty glade
#

are you often checking from the same x,y? you could just sort the allObjects whenever there's a change, if so

limpid prairie
#

for stress testing, like i am assuming worst case

limpid prairie
#

cause that x,y is moving.

#

sorting allObjects each time it moves would also be bad yeah?

misty glade
#

if you don't care about memory usage, you could cache the distance of each grid element to each other (x,y) in the grid and then it's just a lookup, but the memory usage for that would be O(n^2)

limpid prairie
#

That's interesting. That's something I can check out

#

and I'll check out octree

misty glade
#

the memory use there might be more impactful then the CPU use though tbh, and would bloat real fast if your grid is large

sly grove
misty glade
#

yeah

#

@limpid prairie oh also, how are you finding the distance?

sly grove
#

it depends on the access pattern frankly - are we doing a lot more reads than writes? If so such a thing might make sense.

misty glade
#

like, are you just using your own formula?

limpid prairie
#

btw is octree made for 3d points?

#

would i use quadtree since im sort of doing this in the 2d space (ignoring y)

sly grove
#

probably?

#

idk haha

#

Ok yes, I looked it up - quadtree is the 2D analog of Octrees so yes.

sly grove
misty glade
#

catchy image

#

:0

#

quadtrees remind me of that HTML game that was popular a few years ago.. i can't remember the name of it but you popped bubbles of an image and it made smaller and smaller bubbles until you had uncovered the image

sly grove
#

It reminds me of a Mondrian painting

alpine adder
#

has anyone run into a similar problem to this java.lang.RuntimeException: Unable to get provider com.*** My project is currently failing on startup due to appcenter

sly grove
vestal condor
#

is it safe to use gameobjects as dict keys

untold moth
fierce quiver
vestal condor
#

I'm doing this map system where a game object can optionally attach itself to a map manager, which keeps a Dictionary<GameObject, Sprite> to display

#

It can also remove itself by telling the map manager. I'm wondering if multiple game objects will ever share a hash or something

untold moth
#

Just remember that a GameObject can get destroyed, which will cause an undefined behaviour, since dicts can't have null keys.🤔

vestal condor
#

yes, precisely that

vestal condor
#

On update I also have this thing that also checks the dictionary for any non existent game object keys and removes them from the dictionary

#

I can think of instead using a list of key value pairs instead so there's no need to worry about dictionary keys being null but performance wise that would be O(n) instead of O(1)

#

for insertions and deletions

untold moth
#

I'd guess that it would hold a reference to the wrapper object. I think when unity objects are destroyed, they're not actually destroyed on the C# side, but they artificially return null. The reference is still there untill the GC can collect it. Might be wrong.

fierce quiver
flint sage
#

Even if you have objects with the same hash in teh dictionary it'll still give you the right object

flint sage
#

A dictionary has buckets (indexed by the hash), so if you have multiple items with the same hash it just has multiple items in that bucket, then it uses normal equality comparison to find the right object

vestal condor
#

what is the hash conflict resolution used by c# dictionary?

fierce quiver
vestal condor
#

I suppose it only occurs if the bucket contains more than one thing

#

which for a large enough hash table shouldn't happen

flint sage
#

Yeah it only happens if you have a lot of duplicate items

fierce quiver
flint sage
#

Hashes don't guarantee uniqueness

fierce quiver
#

But you see, I can always stick a knife on myself, doesn't mean that it's a good choice of an action to be done

flint sage
#

They just guarantee that 2 objects with different hashes are different, 2 objects with the same hash can still be different (although unlikely with a good hash method)

fierce quiver
flint sage
#

I suppose

muted root
#

How do you import a png at runtime while keeping it's transaprency ?

#

Using Texture2D tex = new(2, 2, TextureFormat.RGBA32, mipmaps) with bilinear and repeat wrapt mode at the moment

#

Then load the image but all the transparency becomes black

#

The fence shouldn't show the black part and the ground black part should be transparent, revealing the grass underneath

#

I tried settings the pixels but still no luck. What am I missing ?

rugged radish
#

I'd look into TextureImporter.alphaIsTransparency
it says that it's intended to be used in the editor tho
but black pixels are most likely caused by alphaIsTransparency == false in your texture

long ivy
#

sounds more like a material problem to me. Are you using a shader that supports transparency?

regal olive
#

Hey, how can I recreate this in Unity?

obsidian glade
potent forge
#

GUI.HorizontalScrollbar
it is impossible to change the y size of this bar

#

and i just searched how to grow everything with GUI.skin

#

but there is almost no any information about this thing

potent forge
#
 GUI.skin.horizontalScrollbar.fixedWidth
 GUI.skin.horizontalScrollbar.fixedHeight
 GUI.skin.horizontalScrollbarThumb.fixedWidth 
 GUI.skin.horizontalScrollbarThumb.fixedHeight

nvm found a way to do it with gui.skin

wintry pawn
#

Hi everyone, I'm using multiple adittive scene for a dungeon instanced system. So I load the same level over another so the players can play but not see each other.
It work great but... navmesh is global. It also loads all the navmesh one over another and server side it's a mess. Is it possible to have navmesh working on local scene and not globally?

wintry pawn
#

@fast pagoda so if I have multiple navmesh components one over another they don't merge in one?

wintry pawn
#

ok, will try. A new question for you @fast pagoda . I have also some navmesh obstacle. In this case do they work locally on the local scene or they work on all scene? I need them to work locally only on one navmeshcompontent and not on all

fast pagoda
#

but by default all obstacles should work on all navmeshes IIRC

wintry pawn
#

@fast pagoda need to test. Because client side players load only one scene and have of course only one mesh. But server side I load all scene on over another with local physics and it's there that is causing problems

#

I was also thinking to offset every scene a bit so navmesh and navmesh obstacle don't overlap. But yeah, not 100% perfect

#

thank you for the help vision!

royal patio
#

I'm working on a dungeon generation algorithm, I am generating rooms in a grid and I am using the BFS to find the shortest path between two rooms to create the hallways. However my BFS implementation doesn't seem to be working.

    List<Vector2Int> BFS(Vector2Int src, Vector2Int dest) {
        List<Vector2Int> queue = new List<Vector2Int> (),
                         path = new List<Vector2Int> ();
        List<Vector2Int> adj_nodes = new List<Vector2Int> ();
        Dictionary<Vector2Int, Vector2Int> path_dict = new Dictionary<Vector2Int, Vector2Int> ();
        bool[,] visited = new bool[roomCount, roomCount];
        Vector2Int node, prev = src;

        queue.Add(src);

        while(queue.Count > 0) {
            // Get first node and dequeue it
            node = queue[0];
            queue.Remove(node);

            adj_nodes = GetNeighbors(node);
            foreach(Vector2Int item in adj_nodes) {
                if(!visited[item.x, item.y]) {
                    visited[item.x, item.y] = true;
                    queue.Add(item);
                    path_dict.Add(item, node);
                    if (node == dest) {
                        print(string.Format("Exit node = {0}, Destination node = {1}", node.ToString(), dest.ToString()));
                        queue.Clear();
                        break;
                    }
                }
            }
        }

        print(string.Format("Source = {0},  Destination = {1}", src.ToString(), dest.ToString()));

        PrintPathDict(path_dict);
        Debug.Break();

        // Backtrace
        node = dest;
        while(node != src) {
            print(node);
            path.Add(node);
            node = path_dict[node];
        }
        path.Add(src);
        return path;
    }

#

The problem is that the BFS never find the dest node for some reason

#

The if(node == dest) is never executed

#

The GetNeighbors just return a list with the (x-1,y) (x+1,y) (x, y-1) (x, y+1) positions of the node

royal patio
#

It makes more sense to be item not node to be honest

sly grove
#

Or at least:

            node = queue[0];
            queue.Remove(node);```
Should be:
```cs
            node = queue[0];
            queue.RemoveAt(0);```
#

(though the queue would be more performant)

#

Also your GetNeighbors implementation would be helpful to see

undone coral
#

visited should be a set

#

probably your getneighbors is wrong

#

it looks like you actually have something almost exactly CLRS

#

why not use it exactly

#

use the same words

royal patio
#

Sorry for not including the GetNeighbors function but it's really nothing interesting

    // Get neighbors for BFS
    List<Vector2Int> GetNeighbors(Vector2Int position) {
        List<Vector2Int> neighbors = new List<Vector2Int>();

            // Neighbor on the left
            if(position.x - 1 > 0) {
                neighbors.Add(new Vector2Int(position.x - 1, position.y));
            }

            // Neighbor on the right
            if(position.x + 1 < roomCount) {
                neighbors.Add(new Vector2Int(position.x + 1, position.y));
            }

            // Neighbor above
            if(position.y - 1 > 0) {
                neighbors.Add(new Vector2Int(position.x, position.y - 1));
            }

            // Neighbor bellow
            if(position.y + 1 < roomCount) {
                neighbors.Add(new Vector2Int(position.x, position.y + 1));
            }

        return neighbors;
    }
royal patio
royal patio
sly grove
royal patio
#

Based on the Debug.Log there are times that it never reaches the destination even is a simple grid like

Room None Room
None None None
None Room None

and others that the destination is inside the path_dict but it is ignored

hollow garden
#

ah wait misunderstood i think

alpine adder
#

any ideas why an iphone build would be 200mb larger then an android build? the only difference is the Iphone build has arkit as well as standard unity ar foundation components associated. where the Android build does not include AR stuff

sly grove
hollow garden
#

Yeah i misunderstood, i thought the message after you suggested to use a Queue was to change those lines to account for the Queue

severe grove
#

Anyone have experience parsing strings? I am looking to perform a check then cut or leave a string based on what I find. Any tips on how to perform it? here is some pseudocode to illustrate ```
var foo = "@CheckFlag[ExampleFlag, -1] (Phrase to return.)";
if(foo.Contains(@CheckFlag))
{

        foo = Data.Flags[ExampleFlag] == -1 
            ? foo.Replace("@CheckFlag[ExampleFlag, -1] (Phrase to return.)", "Phrase to return.")
            : foo.Replace("@CheckFlag[ExampleFlag, -1] (Phrase to return.)", "");
    }```
undone coral
#

unity binaries uncompressed are about 90MB nowadays. in two architectures that's 180MB. system iOS frameworks are not linked statically, unless they happen to be included by your plugins for some reason

alpine adder
undone coral
#

so probably @alpine adder it's the two ios architectures

#

it's not going to be ARKit

#

i haven't done it in a while, but i believe unity's xcode project specifies both arm7 and arm64

alpine adder
#

I see

undone coral
#

this is sort of a red herring. the app store only delivers the arches your device needs

#

you should start optimizing build size only at the end of the development process

#

you can try building an empty project to set your expectations

#

i believe a typical small unity game on iOS is around 25MB

#

over the air

alpine adder
severe grove
undone coral
#

the xcodearchive and what you upload to the app store are not the over the air sizes

alpine adder
#

whats interesting is we removed 150mb on our android

#

but the iphone didn't move

undone coral
#

well what did you remove?

#

have you tried using Build Report Tool?

alpine adder
undone coral
#

hmm

#

are you working on a visual novel

#

and are you placing files into StreamingAssets?

alpine adder
#

files are in resources. and we are making a item design applicaiton essentially

#

so just a ton of textures

undone coral
#

okay

#

my takeaway is that you have no idea what's going on 🙂

alpine adder
#

yup 🙂

undone coral
#

i think you should download/buy the Build Report Tool asset and start there

#

changing the file format from PNG to JPEG had a side effect that improved the build size

#

but it isn't why the build size improved

#

for example, if you did jpeg compression 10 instead of 1, the build size would not improve

#

changing from PNG to JPEG changed your import format (which is what really matters) from one that included lossless alpha by default to one that did not

#

your build doesn't ship PNGs or JPEGs.

#

you shouldn't have anything in Resources. you shouldn't use Resources.

alpine adder
undone coral
#

if you want to reference a list of images, create a Sprite[] on a component and drag and drop them into that field in the inspector

undone coral
alpine adder
undone coral
#

i think intellectually you see what i am saying

#

changing the format didn't reduce your build size

#

changing the import format in the inspector did. that occurred as a side effect of changing the image format

#

does that make sense?

alpine adder
#

that does make sense

undone coral
#

but when i say files, and i think this is one of the things you are now getting a better understanding of, i mean imported files

#

there are no PNGs or JPEGs in your build. there's a compressed texture format that is created, platform specific

#

clearly, for android, the compressed texture format is idiosyncratically set up to be a more compressed format than the one for iOS

#

evne though "the files" are the same

#

you have seen this in the inspector, it's at the bottom.

#

build report tool can help you see all these things

#

removing files from your Assets/ directory typically does not change build output size, however, in a resources folder it does.

undone coral
#

yes.

#

you should never use the Resources/ folder

#

the worst reason to use the Resources/ folder is to retrieve an array of files via Resources.LoadAll

#

because that just means you haven't discovered that you can select multiple files in the project browser, then drag and drop them onto an array field

#

alternatively, if your file structure is complex, make an editor script that goes through your assets folder and assigns the array field for you.

alpine adder
#

I can get that going

#

I did not know that

undone coral
#

well

#

i think you should use this build report tool

alpine adder
#

I am purchasing now

undone coral
#

cool

#

it's really good

undone coral
#

i really doubt that vector2int doesn't have an equality operator

#

it's possible

#

you might just have to compare its components.

alpine adder
# undone coral cool

you sir. are amazing. doing the build report now but just those sentences are 10/10

#

Thank you +100 overflow points

undone coral
#

np my dude

#

now, why does unity not have a runtime compressor so that you can use JPEGs directly? i don't know

#

the performance tradeoff would be worth it for many use cases

alpine adder
#

this tool is amazing as well

#

just ran the android going to run ios here shortly

undone coral
alpine adder
undone coral
#

the appstore file is a red herring

alpine adder
#

I see so in general unrelated and not much I can do there

undone coral
royal patio
#

I mean just node = new(); doesn't really make sense

undone coral
#

don't worry about it

#

there's nothing wrong with this code

#

something else is wonky

ebon cobalt
royal patio
#

Yikes

#

I found it

royal patio
alpine adder
#

@undone coral just finished ios and android build size and they are basiaclly the same size when you down into the data it shows. the ios build is technically 1g it says but thats because it genreates an xcode file not the ipa itself. we will have to tackle the things this build report points out and that is probably the best we can do

quiet bolt
#

you just need to use the right version that supports it

#

Unity 2021.3.5f1 is one version that supports it

regal olive
#

I have to pass the static TagManager.PlayerPrefString which (as obvious by the name) is a string that is cached in the tag manager. I need to pass the TagManager.PlayerPrefString into the serializefield/ref

#

I could type up the string, but I would like to pass in the cached ref

regal olive
nocturne tusk
quiet bolt
nocturne tusk
#

oh 😔

quiet bolt
#

i mean you could try dotnet 6 stuff

#

im not all too familiar with dotnet things tbh

#

i just try things until i get errors lol

nocturne tusk
#

dotnet 6 is sweet, dotnet 7 is even better

#

just don't know which decade Unity is going to support them

quiet bolt
#

oh yea

#

i do know that e.g someArray[^4]; also works in unity

nocturne tusk
#

that's dotnet 5 i am pretty sure

quiet bolt
#

oh 💀

fresh salmon
#

(whispers) static abstracts in interfaces

sly grove
nocturne tusk
quiet bolt
nocturne tusk
#

also ref fields ♥️

quiet bolt
#

my fav thing in this video

nocturne tusk
#

oh C# 8.0, that's not even dotnet 5 😳

#

well i havent worked with unity in a while

quiet bolt
#

is new(); c# 9.0 things?

#

wait hollon, i can see what c# version specific unity releases uses, let me find that page real quick

fresh salmon
#

I love these videos lol
January 8, 2022 new C# features for Unity!!
Meanwhile C#8:

quiet bolt
#

lmfao

#

but it's in Unity tho

nocturne tusk
quiet bolt
#

oh wtf

#

im so confused then

#

also according to the docs, 2021.3.5f1 uses 9.0

nocturne tusk
quiet bolt
#

¯_(ツ)_/¯

#

it says this tho

nocturne tusk
#

I want C# 11

fresh salmon
#

In 10 years, let's be patient

nocturne tusk
#

yes the next decade

#

Unity will have support for C# 11 when we colonize mars

fresh salmon
#

And when .NET15 will be released on the usual November

woven kettle
#

Guys my UNITY EDITOR CRASHED ON ME!

#

I couldnt open it at all except in the SAFEMODE

#

The scene became BLACK all the sudden

#

I assume that is what is causing it

#

alls the sudden BOXCOLIDER is not serialized

#

I have BoxColider as a parameter in one of the functions public void SyncWalls( Vector3 position,BoxCollider col){ //do stuff }... What is wrong with that ??

long ivy
#

step 1 to resolve "Unity is giving me this weird compiler error" is deleting the library folder and opening the project again to see if it goes away

woven kettle
modern cradle
#

hey is there a way to make a scriptableobject that maps Interfaces to classes?

digital osprey
#

sorry to mention, but do you ever use mysql plugin on droplet ?

woven kettle
#

Unity 2021.3.4f1

#

should i switch to unity 2021.3.5 ?

#

is it a unity issue ?

nocturne tusk
#

(this is why you need git)

long ivy
#

what is the stacktrace? that error looks like it comes from Mirror, based on some google-fu

chrome glade
#

hi, I am simon & I am currently creating a software in which you can calculate your average score in school. I am done with the GUI, but still need help for the logical part. Would anyone be so kind to support me?

unkempt moat
#

Hello !
I'm using Netcode for a multiplayer game, and need to use the component "ClientNetworkTransform".
But I can't find it...Do someone would know where it is and how I can implement it to my project please ?

fallow dune
#

I need to check if the player movement direction is directly opposite to the surface normal of a surface.
SO if the player is running left into a wall, the surface normal should point right?

#

I have the raycast hit.normal

wicked laurel
#

@unkempt moat if you are using netcode for gameobjects they have active discord (Unity Multiplayer Networking) where they will help you (look it up can't post invite links here)

unkempt moat
novel plinth
little kettle
#

Hey! I have a question regarding scene rect selection when using a custom VertexAttributeFormat for the vertex positions. Our game is voxel based and due to our very specific setup we can drastically reduce the vertex buffer size, i.e. have 8 bits per axis instead of 32. In code this looks like this:

new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.SInt8, 4)

We decode this position in the shader and we can render our object without any issues. By overwriting the "Picking" and "SceneSelectionPass" passes in the shader we can enable proper picking support in the editor as well.
However, rect selection seems to use a separate system which seems to make intersection tests with all renderer components. Since our position format is not what this rect selection expects we get errors.

Is there a way to support rect selection properly when using a custom format or is there at least a way to exclude the object from the rect selection?

hushed fable
novel plinth
#

There's a hope, that is until their migration to CoreClr complete

hallow cove
#

hello everyone, so I'm making a visual script editor, and I can't figure out how to get MethodInfo, FieldInfo and PropertyInfo types

#

like, transform for instance

#

how can I get it's type?

#

.GetType() doesn't seem to work

hushed fable
hallow cove
fresh salmon
#

.transform being a property, getting it via reflection gives off a PropertyInfo instance. From there you can get its property type

hallow cove
#

how exactly?

austere jewel
#

You have a MethodInfo? What do you want to find out about it

#

what it returns?

hallow cove
#

oh ok

hallow cove
austere jewel
#

They're all pretty well named

hallow cove
#

I'll try to figure out how to get it's parameters as well

fresh salmon
#

I'll redirect you to the official docs on reflection at this point

hallow cove
#

thanks a lot!

fresh salmon
#

You won't find any info on this on the Unity docs, you'll have to do this from the C# docs directly

#

As reflection is pure C#

hallow cove
#

yeah

#

thanks lots again!

supple helm
#

Hello, i'm creating Texture2DArrays as containers for procedurally generated textures to feed into a shader that does more processing, i'm using arrays to work around the sampler limit.

My setup worked using Atlases but had some troubles with tiling. I'm creating these bundles in memory feeding them to a shader and baking output then disposing of them with the only thing being written to disk is the output.

however with Texture2DArray, i'm having trouble assigning them to the material without creating an asset first, which require a lot of time writing to disk.

I've also tried using a RenderTexture as an intermediary and assigning that to the material, however then the shader would only treat it as a single texture despite the inspector showing an array.

Is there a way to create Texture arrays and consume them without writing to disk ?

-solved, i wasn't using Apply() while keeping them readable after editing them ...

hallow cove
#

why doesn't this work with an actual get set property?

objectField_BehaviourObject.BindProperty(serializedObject.FindProperty("behaviour"));```
novel plinth
#

If I were you, and if I knew I'd be working with bunch of reflections, I'll tag all those(methods, properties, etc) with customAttributes... it will make your life much easier

true plume
#

Hello guys, I have a question. I want to create a magazine (UI). I want to create a scriptable object which contains strings and images.

Like a list:
First element: String
Second element: Image
Second element: Image
Second element: String

real ivy
#

Hello guys, if anyone uses PlayFab

I have a short question, how do I call or get player's Display name ?

undone coral
little kettle
# undone coral yes, mudbun does something similar. you can look at their source

Thanks for the suggestion! Seems they are using a custom renderer component (with custom selection) and when they transform their object to a mesh they are using the default mesh layout with 32 bits per axis for the position. Ideally I'd like to keep the mesh renderer component and the Unity selection logic and just extend that but it seems to be quite locked down.

serene pawn
#

Hey guys, can anyone help?

How bad will it affect the performance if a "if (component == null)" is called in the update method each frame? component in this case is a reference to the component on the gameobject

Will this be bad for performance, how expensive is a null check?

sly grove
#

is there a reason you need to run it in Update though?

#

seems like something you could check in OnEnable and then again whenever component is assigned.

serene pawn
# sly grove is there a reason you need to run it in Update though?

Well it's complicated, I have a script that uses a component from the same object. Usually you would just assign it in the start or awake method and thats it, right? Well in this case i also need to access it while the gameobject itself is disabled so start and awake havent been called. so i made a get-set method, and inside the get part i check if it's equal to null and if it is, i assign GetComponent to assign a value to it. but i use this variable in lots of places lots of times, so each time it checks if its null or not, even long after it has already been assigned a value. Do you know if this is the best method to do this and if the performance will be unaffected?

sly grove
#

Why would you need Update here?

serene pawn
serene pawn
sly grove
misty glade
#

Hard to ... solve/profile issue. I've got this loading screen doing some starfield animation.. it's probably clunky, but I didn't think performance would be an issue for the magnitude of GOs and tweens/coroutines in play. Unfortunately, when connecting to the server, I get stuttering and hiccups. It might be the networking library blocking the main thread since it's not async or unity async, but .. I don't really know how to debug/solve this and I'd like to make it a bit smoother. Any general ideas how how to debug/profile/identify the issue..?

sly grove
misty glade
#

Hm.. OK, I'll give it a shot. I haven't dabbled too extensively with the profiler.. I probably should get around to learning to

#

I looked at it a few weeks to and realized my Action event notification framework.. sucked

#

yup, networking 😐

#

Thanks PB

serene pawn
# sly grove You can always use the profiler and check.

Never used profiler before, I checked it out. When im not doing anything and just staring at the profiler while my game runs it shows most of the stuff is between 5ms and 10ms with occasional spikes to 16ms or slightly above. (theres like 4-5 of these spikes on my screen at once). Does this stuff mean anything? Is it good or bad?

sly grove
misty glade
#

Profilers generally (I don't know unity's specific details) measure how resource usage for stacks.. so if you think you're having a problem, you .. profile that area and investigate

#

just running it "all the time" to review your entire game might not uncover anything unless it's extremely egregious

#

Like... rebuilding a UI and doing multiple GetComponent or FindObjectOfType every frame................ not that that's EVER happened to me in the last two weeks

#

👀

serene pawn
#

Well I have been avoiding all bad practices the entire time (For example i dont use findobjectoftype at all), so i hopefully dont have any egregious stuff. Do these spikes im getting mean bad things or is that just normal stuff?

#

And yea i was looking at just the general thing not a specific area

misty glade
#

looks like the networking lib i'm using supports connecting on another thread but.. no idea how to do that

#

16ms spikes are probably nbd, likely just unity player issues

sly grove
serene pawn
misty glade
#

Should I use the unity IJob system to handle this connect code? Or should I roll my own thread using native C#

misty glade
misty glade
regal olive
#

i need some help
i made code for a cutscene where the navmesh agent component is disabled until the cutscene starts
but when it starts, the component is enabled again, but the character doesnt move
things to consider:
-The Area is baked
-I have a valid script for AI navigation
-There are no errors
-Ive seen with my own eyes that the component does get disabled and then enabled again but the character doesnt move

sly grove
#

make sure you're looking at the right frame

#

Or if that is the frame, then you're fine because 2.5ms equates to about 400 FPS

regal olive
#

praetor

#

is there something im missing?

misty glade
# regal olive praetor

Don't @ people directly unless they're.. expecting it.. If you ask a question and don't get an answer, it might be because no one knows, but it also might be because the question isn't... clear enough and people don't necessarily want to engage and help you clarify the question. 🙂

This question belongs in #archived-code-general, though. I don't have experience with navmashes specifically, but just enabling a component may not do what you need it to do - you probably have to tell your character (in script) that the navmesh now exists and to start navigating

regal olive
#

dude

#

wtf

serene pawn
# regal olive .

you said the component gets disabled and enabled again and the character doesnt move. maybe after it gets enabled again you have to reassign a destination to him? cuz maybe i you assign the destination and then disable and enable the script it forgets its destination

regal olive
#

does it look like i pinged him?

#

i said his name

#

thats not pinging stupid

regal olive
#

its still there

#

i think im closer

#

since there is now an error

#

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.

#

it says that even tho i have baked the ground and he should be able to walk on it

serene pawn
#

it means hes not on the navmesh when you are calling SetDestination

regal olive
#

he is tho

serene pawn
#

maybe hes in the air or a couple millimeters off the navmesh

regal olive
#

nah

#

cause when i get rid of the enabled = false

#

like when i start the game, he is moving and it works

tender light
#

hey guys. Did not use Unity in a while. How are the interfaces in C#? 🤔
I remember having issues with them where if the object got deleted its reference in C# via interface would say its not null for a few frames after that. But would crash when accessed.
Does that still happen?

misty glade
#

Sort of - you typically don't manage access to unity GameObjects directly, and you can't check to see if they ==null since unity overrides that operator

#

But I don't really understand your question - there's obviously a way to delete gameobjects, components, and normal C# POCOs if you need to

misty glade
tender light
misty glade
#

So - yeah, that might not be related to the interface but more that MonoBehaviour - the class from which all unity objects derive - has it's own GC behaviour and operator== is overloaded

#

in general you're not supposed to use someObject == null in the unity world if someObject is of type MonoBehaviour

#

And even though that post is now 7 years old - it's as relevant as ever since this question comes up all the time. 🙂 It hasn't been changed. As far as crashing unity when doing that from within an interface, I'm not aware of that issue specifically..?

undone coral
# misty glade

on the one hand, in unitask this is easy to solve - it has helpers for the threadpool. but if you use ONLY threadpool for async, you don't need it. i suggest running the network tasks on the threadpool.

#

you will probably want await UniTask.SwitchToMainThread() though, if you want an idiomatic way to get network messages into your game

#

using async will ensure that your stacks still look like that - super legible

#

it is extremely valuable to have stacks that look the way they do in your code right now

undone coral
#

to determine if spikes are real or not

#

there's a ton of code, especially in scriptable render pipelines, that causes spikes in the editor because it's editor-only but in the runtime assembly

misty glade
#

I already "fake implemented" it just using async ... dangerously. Because that's how I roll. 😉

#
_ = ConnectAsync(address);
private async Task ConnectAsync(IPAddress address)
{
  await Task.Run(() =>
  {
    _ruffleSocketClient.Connect(new IPEndPoint(address, GameSettings.ServerPort));
  });
}
#

👀

#

I'll add a cancelation token to it later in case it kabooms

#

(which I can watch for in Update())

misty glade
#

yeah, why?

undone coral
#

connecting in UDP world is instantaneous because... there is no connection

#

i guess they implement a connection over udp

misty glade
#

sorta - this is reliable UDP so .. there is actually a connection with handshake/challenge/etc

undone coral
#

yeah

#

and they don't provide their own async methods huh

misty glade
#

tbh i'd use TCPIP but i couldn't find a library I liked

#

refactoring it out later for a different library wouldn't be hard without how i setup my networking interfaces internally

#

pretty much everything on both server and client are routed through two methods (aside from all the connection stuff): SendMessage() and HandleMessage()

#

if you have any managed C# tcpip libraries you're aware of, by all means let me know

undone coral
misty glade
#

yeah - I don't need any of the RPC stuff, I've rolled my own messaging framework

undone coral
#

http/3 webtransport is essentially grpc over QUIC (i.e. UDP)

#

but there's no http/3 for unity.

#

there's barely http/2

misty glade
#

I probably could just go TCPIP and .net Socket but ... work

undone coral
#

yeah

#

it's sort of not worth optimizing in the grand scheme of things

misty glade
#

the rUDP library I am using has some really nice features that seem like they should be built into System.Net.Sockets - connection challenges, pooling, etc

#

connection challenge especially in this era of ddosing for fun

long ivy
#

are you moving the plane and camera in sync (FixedUpdate vs Update/LateUpdate)? You'll see that effect if there is a mismatch

frozen imp
#

@strange cradle Don't cross-post, pick one channel

teal scroll
#

can someone explain why the unity debugging editor shows me "My Cell : None (Cell)" as None even though it is being set?

#

Cell is a class that is not a monobehaviour

misty glade
#

You still have to assign it - either in code or in the editor

#

You've declared it but not assigned anything to it

teal scroll
#

well i am assigning it in code

misty glade
#

That's fine, then, it'll work properly in the game

teal scroll
#

it shows when i debug.log it

#

but it doesnt show in the editor

#

does it say None because it is not actually a gameobject or a monobehaviour?

misty glade
#

Are you looking at the prefab in the editor? or the instance of the game object in the scene

teal scroll
#

its the instance of the gameobject

misty glade
#

take a screenshot of your entire unity client again - not just the snipped inspector view

teal scroll
misty glade
#

can you show me the code for RoomData.cs?

teal scroll
misty glade
#

seems ok but could still be a few other things.. Are you sure there's only one room in the scene?

#

add this to your debug.log:

#
Debug.Log($"setting cell on {GetInstanceID()} to {cell}");
#

oh, it's private

#

the editor can't see it

teal scroll
#

oooooh

#

but i thought it could since im in debugging mode

misty glade
#

i mean, i wasn't even aware that the editor serialized private fields using the debug view like that, but now i know

#

i think you can make them show up if you annotate it with [SerializeField] but .. tbh i can never remember how that works with private fields

teal scroll
#

yeah now it works

#

but im so confused why can it show private fields in debugging but not this one?

misty glade
#

apparently it reflects all the fields for help debugging, but it can't access the value of the field? 🤷‍♂️

#

may as well just make it public, or make some other public readonly field for unity so you can see the details of a cell

teal scroll
#

another example here:
it shows my private Dungeonalgorithm script in my dungeon manager

#

maybe because this one is on the same object/instance?

#

and it can show it while debugging if its on the same object but not if its refencing a different one

misty glade
#

no idea 🤷‍♂️ It's sort of a weird way of doing it, though. If you need to view/access it, serialize it or make it public.. I've needed debug mode in the inspector pretty rarely, and usually because I'm doing something wrong 🙂

teal scroll
#

i mean i guess, but im mainly using it because i want to sort of mimic a readonly serializefield

#

cause this is for things i dont actually want to put stuff into

regal olive
#

how can i copy a gameObject without Instantiating it? i have a prefab, and i want a class hold that prefab copy without referencing the original nor actually showing it ingame.

scenic forge
#

Will Burst optimize away property getters/setters so they are basically zero cost comparing to a field?

buoyant nacelle
#

Can someone help me with an advice of how to approach a problem, please. I am making a Targeting System which would allow to pick Object in Aoe or pick the closest object. I want to be able to pass what kind of object I want to select. So, I should have types like Team(team1, team2), Object Category(Unit, Structure), Types for each category. For example, I want to pick only Enemies and Heroes, or only Allies and Structures or only Units (which includes heroes and other units) and then return a group with them.

I am struggling to understand how to make subtype. And then I do not understand how to abstract picking criteria. How would you archetecture this? It is MOBA, so it should be efficient

hoary pendant
buoyant nacelle
gentle yew
#

Hey, is there a way to run Unit Tests on Android and iOS? I feel like I've seen that documented somewhere but I can't find the documentation for it

hoary pendant
patent vine
#

I'm trying to generate the bolt thingy, And I get this error and then I can't make units in the graph, Can someone help me please?

buoyant nacelle
buoyant nacelle
buoyant nacelle
#

I thought about adding them in the dictionary, but I think looping through them would be too intensive

gentle yew
buoyant nacelle
#

I can have 100 units on the map

#

Or more

regal olive
teal scroll
# misty glade no idea 🤷‍♂️ It's sort of a weird way of doing it, though. If you need to view/...

i figured it out. I wasn't giving the setter method an instantiated version of the prefab. I was giving it a prefab.
I wanted to set the Cells element to the object and the Object's cell to the cell. It put the cell's element as the Prefab and then set the prefab's cell as the correct cell. But i wasnt changing the actual gameobject's cell. I'm not quite sure why it was showing when i changed it to public but that was the underlying issue i was facing.

gentle yew
#

@buoyant nacelle hmm... Dictionary sounds like it could work... You would have Dictionary<Type, Object[]> where Type is your group classification or whatever, and Object[] is an array of objects that meet that criteria.

When you want to select multiple types of units, you get the values from the keys and combine them into one single array

gentle yew
#

@buoyant nacelle The issue with that is... redundancy.. if you have units that meet multiple criteria, you'll have to repeat them per key... now, if that is optimal or not, is up to you

hoary pendant
gentle yew
#

You'll essentially have O(1) time complexity on this (if we ignore merging arrays somehow) but space complexity would be potentially O(N^N) which is horrid

#

+1 with Joseph. Seems like it would get tricky real fast if you want to inherit from 2 units suddenly

misty glade
buoyant nacelle
#

Need to think of a better way

hoary pendant
buoyant nacelle
#

Don't see how interfaces can help here

misty glade
#

I'd probably lean on linq and lists to select from a list of target objects that match some criteria.. like..

public class ThingInGame
{
  public string Team = "GoodGuys";
  public ThingTypeEnum Type = ThingTypeEnum.NPC;
  public bool Invisible = false;
  public Vector2 Location;
}

// AOE spell that targets teammate NPCs that aren't invisible:

Vector2 myLocation;
List<ThingInGame> targets = allThingsInGame.Where(x => x.Team == "GoodGuys" && x.Type == ThingTypeEnum.NPC && x.Invisible == false).OrderBy(x => Vector2.Distance(myLocation, x.Location)).ToList();