#archived-code-general

1 messages · Page 117 of 1

dreamy dawn
#

when I run my game I get like 600+fps, when I activate mlagents-learn I get 10fps, is this normal because it didnt used to do this I think, could it be somewhere in my code that its so slow? what could I look for to identify the problem? I look in profile analyzer but idk what Im seeing there

fluid forge
dreamy dawn
#

its not a constant , its like 10-13

lean sail
#

thats still basically constant

fluid forge
dreamy dawn
potent sleet
#

do they have to be in the resource folder ?

dreamy dawn
#

nice thanks

fluid forge
fluid forge
# dreamy dawn nice thanks

You're welcome.
As you can see on the right side, the blue part is taking a LOT of your FPS, and it says that blue is Script.
So now, on the bottom part (Main thread) you should be able to click on the part that are taking most time.

I would also advise you to swap from Timeline to Hierarchy (Just above main thread, click and change the layout).

glossy cobalt
#

How to handle tilemap walls?

soft shard
#

Just curios if this would be a good approach for what I want to build, im making all my abilities as ScriptableObjects, that I plan to store in typed lists (like List<CarSO>, List<BikeSO>, etc), on a singleton then use that singleton to essentially act as a "shop" for different types of SO's, and allow the player to maintain a small inventory of various SO types, could this have a noticeable memory impact? Are there maybe other ways I could explore as well or should this approach be fine in this case?

dreamy dawn
#

What does this mean

#

so the reason its so slow is because its deciding what to do?

lean sail
#

thats likely your mlagent taking a lot of resources yes

#

you likely dont want to train an agent every single time you play

#

training is very slow from nothing

fluid forge
# dreamy dawn

If you read the code, you can see that your root.DecideAction is taking almost 56 MS.
Which is ... HUGE.

lean sail
#

ive had worse from the editor itself 🤷‍♂️

#

its bad still, but i assume this is only lagging when they are training

viral marlin
#

Is it possible to add a transition in animation controller that can checks if one of the provided values is true? (Like an or statement)

earnest gazelle
#

When do you prefer to define an enum with All, None and other flags (unions) instead of defining an array of a class type
In my view, when values of that enum type do not change (add/remove)
For example days of a week is known.

#

My exact scenario is
Each building/farm can be damaged/destroyed by different animal types
Mamals, insects, birds.
I can define an array of animal type as target

public enum AnimalType{}
public class Animal{
   //...
   public AnimalType Type;
}
public Animal[] Targets;
public bool DamagedByAll;

or
converting that animal type enum to flag enum

dreamy dawn
#

What does Take actions between decisions mean?
if decision period is set to 20 does it mean that for the next 19 steps its going to redo the same decision?

glossy cobalt
#

best way to seperate wall and floor collisions with a tilemap?

dreamy dawn
potent sleet
dreamy dawn
#

yes?

#

I wasnt sure if that toggle meant doing a random action between decisions for learning purposes OR doing the same action for the next n amount of steps

#

ALSO about my low fps, I dont see cpu or gpu maxing out and its struggling with fps

warm wren
dreamy dawn
#

I didnt make that toggle there tho

#

its from mlagents

#

I should prolly have said that?

heady iris
#

you should probably read the instructions...

heady iris
#

unless you're effectively using all of your cores

#

you'll probably be bottlenecked by single-threaded performance

dreamy dawn
#

I should see 1cpu hit 100 no?

void basalt
dreamy dawn
#

so what is bottlenecking then

void basalt
#

I don't know anything about unity's ML agents, but it's a pretty consuming task in general

#

RTX GPUs have cores specifically designed for these calculations

#

like someone else said, you shouldn't be training while the game is running

dreamy dawn
#

so if I run in headless mode, ima see a bottleneck?

void basalt
#

headless mode has nothing to do with this conversation

#

nor is it going to change how the learning calculations get processed

#

Headless mode gets rid of the rendering part. Rendering != machine learning simulation

dreamy dawn
#

I know

#

but Im also not really getting a straight answer why Im not bottlenecking

#

im tryna pull some answers

void basalt
#

I don't think you understand what bottleneck means

dreamy dawn
#

something that runs at max capacity so other stuff has to wait for that thing

void basalt
#

If you have hyperthreading enabled, your cores will not be at 100%

dreamy dawn
#

but what thing is bottlenecking

#

something has to bottleneck

void basalt
#

what

dreamy dawn
#

my gpu is using 23W

#

cpu 50-60W

heady iris
#

i think you need to get a handle on what your code is doing

void basalt
#

Your GPU will only be used in the ML calculations if unity specifically designed it to

dreamy dawn
#

wwhere is the bottleneck

heady iris
#

rather than trying to randomly guess what's happening

dreamy dawn
#

you guys lmao

void basalt
#

If unity hasn't designed ML-agents to use tensor cores, it will not use your GPU

#

your GPU will be out of the picture

#

it does not matter

dreamy dawn
#

tell me how to find out what is bottlenecking then

void basalt
#

lmao

heady iris
dreamy dawn
#

if it aint my gpu its my cpu

#

but if its not my cpu its my gpu

#

so what is it

void basalt
#

simulation code DOES NOT RUN ON THE GPU

dreamy dawn
#

OKAY THE CPU

#

but why is NONE of my cores maxing out

void basalt
#

I already told you about 3 times

dreamy dawn
#

because its hyperthreading okay

void basalt
#

if you have hyperthreading enabled, YOUR CORES WILL NOT BE MAXED OUT

dreamy dawn
#

BUT ONE CORE HAS TO RUN AT MAX??? NO?

void basalt
#

oh christ

#

have fun chem

dreamy dawn
#

how am I using less than 100watts total

heady iris
#

stop trying to stare at your hardware numbers

#

it is non-productive

void basalt
#

The main issue is that you're trying to train during gameplay

#

The training should take place in a separate simulation

#

and it doesn't matter if it runs at 10 fps

#

You feed it an input and get an output. That's how machine learning works

dreamy dawn
#

so you're saying my code is limiting my fps?

void basalt
#

Judging from google searches, it's possible, but has worse performance than the CPU

lean sail
# dreamy dawn so you're saying my code is limiting my fps?

you just need to not train your models everytime u play as i said 2 hours ago. Yes, this is your code, i dont know what answer you are looking for.
There will be some way to store the results, and then all you have to do is let it train once or however many times you want. Look into how ML works, or maybe just an overview of what it is and you will see why it is terrible to use everytime you play. If you dont understand the basics of it, you wont be able to tune it, and you'll wonder why your AI breaks.

void basalt
#

There's also the question of "do I really need a full ML setup in my game?"

lean sail
#

depending on the algorithm used, and the data size, training can take hours. For a game, training an AI to even aim properly takes a long long time

#

as well with what Burt said, a lot of "AI" enemies arent even AI. Just state machines, if statements, and randomness

void basalt
#

Pathfinding as it is, is already extremely expensive on the CPU

#

throwing ML at that is just going to shit on your performance even more

steel elk
dreamy dawn
#

its not for a game

#

Im making a virtual spider

void basalt
void basalt
#

If you can't figure out the basics of ML, you're going to have an awful time.

dreamy dawn
#

prolly

lean sail
#

If the spider is going to try and walk by itself with joints, and you dont have any background in ML, you really wont get anywhere

#

these are the types of videos u see online that take days of training.

dreamy dawn
#

yup

void basalt
#

Hacksmith did this IRL. An entire team of engineers did not succeed with this.

dreamy dawn
#

I made a function that would basically make it walk... really nice in a straight path but then turning becomes an issue. Could I "show" an ML my thing and speed up the learning process?

dreamy dawn
void basalt
#

ML requires a background in mathematics and statistics.

lean sail
#

that isnt how ML works

void basalt
lean sail
#

Look into actual ML like what a reward system is if you intend to continue with this

#

you would need something to tell you spider if it did good or bad, then it will adjust to try and maximize its reward function

void basalt
#

You could look into control theory and PID controllers.

#

again, what you're trying to do is very advanced

dreamy dawn
dreamy dawn
lean sail
#

you need to fine tune your reward system so some inputs are more rewarding than others. No ones really gonna be able to tell you what reward system to use, but if your spider works on joints then a high reward should be walking while not going past its joint limit

#

again though im even skeptical to say that as a high reward. The results are going to be shown after training

dreamy dawn
#

24 angles of how the legs could be turned and im rewarding if its getting closer to the target xd

lean sail
#

yea thats not gonna work

dreamy dawn
#

so you are telling me this is bad?

lean sail
#

i dont even know what that is for

dreamy dawn
#

I kinda knew it tho but like shit its actually bad

void basalt
#

You need to interface with it using the physics engine.

#

Something like addtorque for rotating it

#

which is going to be difficult because of the legs being separate from the main physics body

dreamy dawn
#

Im limiting myself to the ideal world, it has only mass and gravity and 0 friction what so ever

lean sail
#

Your rewards have to make sense as well for the goal, 24 angles -> spider walking doesnt make sense.
You want it to walk towards a goal, so maybe measure how long it took to get there.
if you base it off addForce in some way, one issue becomes that your AI will learn to launch itself to get to the goal in 1 frame and obviously u dont want that

#

addForce was just an example though, if you intend for it to walk only from rotations then u wouldnt use it

dreamy dawn
#

oh so my code wouldnt do that

#

all it does is add between -1 and 1 to the rotation clamped between its min and max rotation

#

oh but even if its a whole degree of movement I guess it could launch itself

#

unless I make the mass to be 999 tons 🤔

lean sail
#

if theres rigidbodies and joints, it may still find a way but 🤷‍♂️ thatll be apparent after training

dreamy dawn
#

You have convinced me

#

aight its done, I closed everything I gave up

#

ill be back in a month to learn ml from start sadok

vale wren
#

is there a way to change the scroll position of a scrollrect while dragging?

#

i'm trying to do a looping scroll, and i've done the math to loop the position back when i hit a certain boundary

#

but when i drag past the trigger, the scrollbar freaks out

thin kernel
#

Hi. A bit of an abstract question.

I always find it hard to organise data when it should be sorted by different values, for example: students, who answering some questions. I need to sort it by students, to know who and how answered on every question, and I also need to sort by questions, so I can get data of how many time specific answer were chosen and how many student answered the correct question per class.

So the difficulty I'm facing, is how to build the structure. I can create class Student who have property "List<AnsweredQuestions>" or I can create class Question, who have property "List<AnsweredStudents>". And either way, when I have to get Information from another structure (for example, when I decided to go with Student class and have to get statistic about all answered questions), I have to make a helper method, that go through all the students list, record all answers information and return it:

void GetQuestionAnsweredCount(Question question, string answer)
{
  int answerCount = 0;

  foreach (Student student in Students)
  {
    if (student.AnsweredQuestions.Find(question).Answer == answer)
      ++answerCount;
  }

  return answerCount;
}

The sample above is simple, but the complexity growth very quickly.

Am I missing a simpler solution? I feel like there could be a pattern to solve this, I hope I described the problem clear enough.

quartz folio
#

Object orientated programming doesn't grapple well with questions like these, where do you put data when it's not really part of this abstract representation?
Personally, I would avoid connecting these two unconnected things inside their own data structure. It doesn't make sense that questions know about students, or students know about questions beyond their ability to answer them or not.

#

So create another data structure from that information that is set up in a way that lets you use it in the way you use it the most

#

You might have a dictionary between questions and hashsets of students who chose certain answers, that way you can look up questions quickly, and find out who answered what, and get the count of each answer quickly.

#

Your above code might then look like:

void GetAnswerCountForQuestion(Question question, string answer) => Results[question][answer].Count;

Whether a student gave an answer:

void CheckStudentGaveAnswerToQuestion(Student student, Question question, string answer) => Results[question][answer].Contains(student);

Which answer a student gave:

string GetAnswerStudentGaveToQuestion(Student student, Question question)
{
  foreach((string answer, HashSet<Student> students) in Results[question])
  {
    if (students.Contains(student))
      return answer;
  }
  throw new ArgumentException($"{student} did not give an answer to {question}");
}

(with the caveat that there is no/limited error handling above)

fervent furnace
#

this is impossible to sort your struct based on two values with same priority
you must decide the most "important" one (ie the value with highest priority in the comparator)

solemn raven
#

hey,
is there's a way to tell unity to write a shader script based on some bools or enums ?

for example

string line = default;
if( x == 1 ) {line = "
        Tags 
            {"RenderType" = "Transparent" "Queue" = "Transparent"}
";}
else{
        Tags 
            {"RenderType" = "Transparent" "Queue" = "Opaque "}
}

and then somehow ask unity to add the line to a script template ?

cosmic rain
#

And use something like sql to query whatever data in whatever form you need.

thin kernel
#

Thank you for the answers, I have to think about it for a while...

cosmic rain
cosmic rain
#

I guess the correct name is preprocessor directives.

#

And more specifically shader keywords

indigo verge
#

Okay, so, I'm fumbling through interfaces right now, and UnityEvents, and I wanted to make sure I was doing this right.

I have a base interface that my Transition Classes inherent from, here:

public interface ITransitionBase
{
    //Holds events for completing a transition or detransition.
    event UnityAction TransitionFinish;
    event UnityAction DetransitionFinish;

    //Holds functions for starting a transition or detransition.
    void BeginTransition();
    void BeginDetransition();
}

and then, to make sure that I can edit TransitionFinish and DetransitionFinish in editor, I've got this in my child classes:

    //When the transition or detransition finishes, these are invoked.
    public UnityEvent OnTransitionFinish;
    public UnityEvent OnDetransitionFinish;

    //Allows for Interface Functionality and Unity Editor functionality at the same time. 
    event UnityAction ITransitionBase.TransitionFinish
    {
        add => OnTransitionFinish.AddListener(value);
        remove => OnTransitionFinish.RemoveListener(value);
    }

    event UnityAction ITransitionBase.DetransitionFinish
    {
        add => OnDetransitionFinish.AddListener(value);
        remove => OnDetransitionFinish.RemoveListener(value);
    }

So I can use something like Thingie.TransitionFinish += ThingToWatchFor, and have that added to the list of functions that will be fired when TransitionFinish happens.

I got most of this advice and explanations on how this works from ChatGPT, so I wanted to poke my head in here and ask around to make sure I wasn't just totally off the mark on how this all works.

#

As far as I can tell, I'm basically using using TransitionFinish as a gobetween for the exposed OnTransitionFinish UnityEvent that is visible in editor, so in code, I can treat TransitionFinish as if it were the same as OnTransitionFinish, right?

indigo verge
cosmic rain
#

I have a slight feeling that it's gonna be a compile error. That's why I asked.

mossy snow
#

it also makes no sense to me why you'd design it like this unless the add/remove behavior for each transition is different. It looks a lot like you're going to copy-paste those event implementations for each derived class instead of making your interface into a base class and implementing them there instead

indigo verge
#

See, that's why I came here to ask, because I didn't even consider the idea of using a base class instead of an interface.

#

So, if I made it a base class, like, "BaseTransitions", and had all my other transition classes inherent from it, I could make a List of BaseTransitions, and that list could contain the inheritors too, and apply the needed functions/events?

mossy snow
#

Yes you could have a list of them. You lost me with the apply thing though, what are you trying to do? Your base class would look something like this:

abstract class TransitionBase {
  public UnityEvent TransitionFinish;
  public UnityEvent DetransitionFinish;
  public abstract void BeginTransition();
  public abstract void BeginDetransition();
}

Derived classes would be forced to implement those two methods, or will be abstract themselves

indigo verge
#

Yeah, what I mean by apply is that I'm basically writing scripts that I can apply to stuff like a pause menu, so the pause menu can have a list of objects that need to transition in color or transform or whatever, so things turning invisible, sliding on screen, ect ect, and the idea is that each thing that needs to transition fires an event when it completes, which allows me to make the pause menu only actually pause the game once all the transitions are complete.

mossy snow
#

yes that'll work fine. If you're doing this in code, using UnityEvents is probably overkill and you'd be better off with a callback instead

solemn raven
#

i need to make a script to write a template shader code based on parameter i gave it

#

then save that file to a local drive. maybe assets/shaders

cosmic rain
solemn raven
#

what ? how ?

mossy snow
#

Shader keywords is the right way to do this, whatever you're doing sounds messy and will be editor-only

solemn raven
cosmic rain
mossy snow
solemn raven
# cosmic rain System.IO.File

could you give me an example ? i still dont know how I could tell script to create shader ?
do i need editor script or monobehaviour ? .. what should I look google ?

cosmic rain
#

A shader is just a text file with the shader extension(for example .hlsl), so you just create a new text file normally, write the code text to it and name it "myShader.hlsl" or something. Check the System.IO.File API docs for the relevant functions(creating/reading/writing to file).

#

You can find many tutorials on writing and saving text files in C#.

#

The editor script can be whatever you want. It doesn't seem relevant to the question at hand.

solemn raven
#

@cosmic rain Thanks a lot ❤️
@mossy snow Thank you ❤️

latent latch
#

The shader itself should expose the queues anyway on the material

#

pretty sure it's always exposed even

indigo verge
mossy snow
#

you can use Action or define a delegate

indigo verge
#

gotcha. I want to be able to edit it in-editor, so I'll probably be sticking with UnityEvents, since this code is meant to be reusable for any kind of transitions (and events playing during them) I might need to do going forward.

thin aurora
thin aurora
indigo verge
#

Yeah. I know UnityEvents are apparently a bit more performance heavy, but all I'm using this for is for firing off functions when a transition or detransition ends, so there wouldn't ever be more than like ten of these happening on any given frame, and even that owuld be a bit obscene for this particular use

thin aurora
#

Well, they might be worse performance wise, but one thing you should remember is that c# is very optimized for anything

#

You could have a million events and the performance difference might not be noticeable

#

You're most likely never going to get to a point where you need to make compromises and leave out features for performance, so don't worry about it. Just be sure to properly use methods, and not do a million things every frame which could be done once for example

indigo verge
#

yeah, I'm just choosing UnityEvents over another callback method because UnityEvents are exposed in editor by default, so I can do more with them without needing to write new code, and reuse them more.

fluid forge
#

Get array of Sprites from Texture2D set as SpriteMode : Multiple ?

indigo verge
#

Okay, so, since my Item scriptableobject has a reference to a prefab, and that prefab has a script that holds the Item on it as well, I can't directly serialize my Item Inventory list to Json, (since it's a recursive thing).

Would it be better for me to make my inventory use item IDs that refer to a dictionary instead of being a list of the actual items, or making a serialization method that saves the list of ID's, then populates the list using the IDs when loading, (Or would it be better to do both?)

mossy plover
#

hey im back with my problem, both rt.rect.height and rt.sizeDelta.y return 0 probably because its grayed, is it possible to get this value?

heady iris
#

well, yeah, it's being driven by a ContentSizeFitter

#

which is presumably on the same object

mossy plover
#

oh yes youre right, it turned out it need one frame to update rectTransform thats why it returned 0
but if you call LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform); before getting value, it will work

heady iris
#

ah, yeah

loud wharf
#

I'm trying to make a deep copy that varies of level and condition through reflection and i'm having problems with arrays. UnityChanThink

heady iris
#

don't crosspost

loud wharf
#

It's beginner. I'll delete the first. UnityChanThink

heady iris
#

k

#

so, what is the problem?

loud wharf
#

the arrays. UnityChanThumbsUp

heady iris
#

well, yes

#

but that's not very much to go on

loud wharf
#

What's the site for posting code again?

heady iris
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

loud wharf
heady iris
#

i should probably ask what you're trying to accomplish here

#

not "deep copy via reflection"

#

what are you trying to accomplish with this?

loud wharf
#

Deep copy using reflection with varying levels of deepness and condition.

heady iris
#

did you read what i just posted?

#

i want to know what you are going to do with this

#

there might be a simpler alternative

#

what game feature are you creating here?

loud wharf
#

Hmmm, i often go to far with these.

But what i do need atm is to duplicate an element for a Scriptable Object.

#

My other deep copy code i got off off internet doesn't work with UnityEngine.Color.

heady iris
#

"duplicate an element"?

loud wharf
#

A class to be exact.

heady iris
#

if you make the class serializable, you could just serialize and deserialize it to get a copy

loud wharf
#

Nah, the problem is UnityEngine.Color.

#

I can't copy it.

heady iris
#

Color is serializable.

#

it's also a struct, so you, by definition, always copy it

loud wharf
#

Wait a sec. UnityChanThink

#
    [Serializable]
    internal class DebugTriggerMechanics : BaseTriggerMechanics
    {
        [Header("Components")]
        [SerializeField] private string str_message;
        [SerializeField] private Color debug_colour;

        protected override void ActrivateTrigger(in Vector2 origin, Vector2 facing_direction, Vector2 facing_point)
        {
            if (str_message != "") Debug.Log(str_message);
        }
    }
#
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0063:Use simple 'using' statement", Justification = "<Pending>")]
        public static T DeepCopy<T>(T other) where T : class
        {
            using (MemoryStream ms = new())
            {
                BinaryFormatter formatter = new();
                formatter.Serialize(ms, other);
                ms.Position = 0;
                return (T)formatter.Deserialize(ms);
            }
        }
heady iris
loud wharf
#

Any alternatives?

heady iris
#

ah yeah, they are, indeed, distinct.

#

annoying.

loud wharf
#

Indeed.

languid solstice
#

hi i made my first game everything seems to work well on the pc but once i put it onto android the buttons in the main menu no longer work. Heres the code for the buttons for reference https://gdl.space/bevizibito.cpp

knotty sun
steady granite
#

I'm trying to expose a method in the inspector with [ContextMenu("MethodName")]
I want to call a [Serializable] class' method from a monobehavior containing this class, is this possible as is or will I need custom editors? Or can I create the [ContextMenu] in the containing class to call this function?

heady iris
#

so you have a nested class?

#

and you want to call a non-static method on that nested class?

heady iris
#

it lets you invoke a method on the MonoBehaviour from the inspector

leaden ice
#

What's the compile error

#

That's the first step

heady iris
#

oh, there's a compile error

#

i just noticed

leaden ice
#

Looks like the constructor needs two parameters

steady granite
#

not sure about the meaning of nested class, but to clarify :

public class Units:Monobehaviour{ 
public Stats stats;
}
public class Stats {
[ContextMenu("UpdateAllstats")]
public void UpdateAllStats(){
//...
}

I know if I use [ContextMenu] in the Units class it shows in right click menu in inspector but is there a way to make it access the stats class methods from Stats within Units

leaden ice
#

Also looks like it's supposed to go on a field

#

Not a method

heady iris
#

nah, it just sits by itself

#

it's like [Space]

#

it's kinda just...there

leaden ice
#

Just read the docs/examples

heady iris
#

i've used it a few times before

leaden ice
steady granite
leaden ice
#

Attributes are never standalone

heady iris
#

oh wait, you're right. what am i on about.

digital fern
#

I already used ContextMenu to call methods from inspector

#

Never made it work with args

heady iris
#

I must have actually had it on a field and just not noticed.

#

ah! yes, this makes more sense now.

#

that's what I used

#

that attribute goes on a method.

#

the attribute must be attached to a method on the MonoBehaviour.

#

i'm still unclear what you want to do

#

you can't just call a method on a nested class -- you don't have a specific instance of that class to call the method on

#

you can, however, call a method on the MonoBehaviour that manipulates an instance of the nested class

steady granite
#

Ok so it needs to be on the monobehaviour, cant put it in the Stats class so that every monobehaviour ( or SO) I attach it tohas the contextmenu option

heady iris
#

Not that I'm aware of.

digital fern
#

Can't make a custom editor for your SO ?

loud wharf
wide needle
#

how do i fix this ?

heady iris
#

weird internal error in the visual studio package, hm

#

i'd hit it with a reimport-all to start

#

go to the project window, right click, Reimport All

wide needle
#

THIS ?

heady iris
#

Yes, that also works

wide needle
#

ok trying

heady iris
#

you may need to update a package

#

i'd hit Ignore and then check Window > Package Manager

#

unsure

static matrix
#

hmm onParticleCollision isn't working

wide needle
heady iris
#

you would want to look at the Visual Studio package

static matrix
#

it isn't ever logging anything, no matter where I put it

wide needle
#

ok

heady iris
#

well, it sounds like NetworkManagerHelper uses it...

static matrix
#

Any reason or exampling on how to properly use OnParticleCollision?

#

because It refuses to work for me

#

where should I put the script with OnParticleCollision for it to detect collison

static matrix
#

yep
im looking at it

#

is the GetCollisionEvents required?

heady iris
#

no, that is used to get the full list of collisions

static matrix
#

ok then

heady iris
#

it can't be necessary for the message to get sent in the first place

static matrix
#
private void OnParticleCollision(GameObject other)
    {
        Debug.Log("Working");
       
    }
heady iris
#

and where did you put the MonoBehaviour that this is a part of?

static matrix
#

I have this basic to test
but the message never shows

#

ive tried it on both the hit collider and the same script that is used on the particle maker object

#

nothing

heady iris
#

i'm pretty sure you have to turn on collisions in the particle system

static matrix
#

they are on

#

ill show the settings

#

it says mixed but it is all the layers

digital fern
#

rofl @heady iris your past self is not helping me at all ! 🤣 (was searching for my problem on the discord, found this haha)

static matrix
#

so any reason why it never triggers? This is very bafffling to me

heady iris
# static matrix

it will not say "Mixed" if you have every single layer selected

static matrix
heady iris
#

interesting

#

machine broke

#

i'm unclear if a Rigidbody needs to be involved

static matrix
#

hmm
ill set it to Everything

#

nope

#

still nothing

open wharf
#

Hello!
I've started using Unity Splines package. There is not a lot of information on the internet. Has anyone done any significant work with this package? I'm trying to connect two objects with a spline that should behave similarly to how nodes and connections work in ShaderGraph or Visual Scripting. My expectation is that Unity spline would change its shape when, lets say, last node is moved (bend along with it). But it really bends only the last segment.

static matrix
#

this is most strange

#

The particles needed to be meshes, not billboards. I settled on using Quad meshes for them, since I just need effectively 2D sprites.
Ohhhh

#

ok

heady iris
#

Ah. That would do it.

static matrix
#

ok

#

tysm

#

dammit

#

that would do it

heady iris
#

I looked right past that myself!

#

it's riiiight at the end

indigo verge
#

okay, so, I'm having a weird issue

#

specifically, I'm having an issue figuring out what the issue even is

static matrix
#

clearly, there is an error of some kind

indigo verge
#

I'm getting these errors on runtime, but I can't actually track down what's causing them. None of my scripts show any errors in visual studio, the errors themselves don't say what script or object is calling them, so

heady iris
#

This looks like an error in the inspector.

#

or in some other chunk of editor UI

#

i would start by restarting the editor

native fable
#

Hi. I have 2d simple mesh. How to convert this mesh to sprite asset?

indigo verge
#

Gotcha

static matrix
heady iris
#

if so, I'd just render it out in Blender

#

you can turn on transparency so that the background isn't opaque

knotty sun
native fable
# heady iris not at runtime, right?

yes, not a rantime. I slice 2d apple image mesh to several meshes and now i want to save this part as sprite assets and add it to scriptable object Parts with unique ID.

#

in unity

heady iris
native fable
#

witout blender

heady iris
#

usually because some internal state has gotten mangled

#

hence starting with a restart

indigo verge
#

yeah

#

now no errors are being thrown up

#

now that I've restarted the editor

#

thank you for the advice! I suppose something just gets confused in my editor over time?

heady iris
#

I often see this in the form of errors in a graph editor

#

something gets lost due to some subtle (or maybe flagrant) design error

#

and then it just falls over and dies

indigo verge
#

Hmm.

#

After some experimentation

#

the errors seem to crop up around my SerializedObjects. I just got an error thrown when I:

  1. Started runtime
  2. Saved a file
  3. Exited runtime
  4. Entered Runtime again (The save list, which is a scriptable object, is updated)
  5. Error thrown:
heady iris
#

does it depend on what you are inspecting?

indigo verge
#

let me see if I can replicate it

#

and if I can, I'll share the code that might be causing it?

#

Hmm. So adding ANOTHER new save file didn't result in a second error being thrown, still just the one singular one.

#

still, I'll make a paste of my Savelist code and post it

#

maybe someone here will see whatever it is I'm doing wrong

gray mural
#

how to set Color in this format?
R [0 - 255]; G [0 - 255]; B [0 - 255]; A [0 - 1]

Each color component is a floating point value with a range from 0 to 1. (UnityEngine.Color)

indigo verge
heady iris
#

there IS Color32

#

which stores the R/G/B/A components as bytes

#

thus, 0-255

heady iris
#

Color32 can implicitly convert to Color, so you can use it anywhere that wants a Color

#

but there's not a huge reason to do that, unless you really specifically need to use the familiar 0-255 range

#

it's so-named because it's a 32-bit color

#

rather than Color, which uses 128 bits in total (32 per float channel)

ember sandal
gray mural
#

does anyone know how to disable scrolling by player in TMP_InputField (or InputField) ?

potent sleet
gray mural
gray mural
#

but it does not work

potent sleet
#

unity tends to use that

gray mural
potent sleet
#

m_VerticalScrollbar

#

look in the docs. only 2 members with scrollbar word in it

gray mural
#

it's protected

potent sleet
#

yeah just noticed

potent sleet
# gray mural

which scrollbar do you see? i never noticed one on InputField

urban marsh
#

Hello everyone !
Is there a way, from a script attached to an GameObject, to clone the GameObject ?
(looking on google, I mostly find things about cloning and duplicating in the interface).

#

Is this actually correct ???
GameObject clone = Instantiate(gameObject);

gray mural
#

so if there is lots of text

gray mural
urban marsh
#

OK, I'm so used to instantiate "clean" Prefabs, I didn't think about using it that way

potent sleet
#

example if it's put in Start it will keep cloning itself infinitely

potent sleet
#

no without while lol

urban marsh
#

yeah, not putting something like this in the start method 🙂

gray mural
# potent sleet example if it's put in Start it will keep cloning itself infinitely

I see, it instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself with a script that instantiates itself...

potent sleet
#

we call that Recursion 🙂

frozen robin
gray mural
heady iris
#

things shouldn't spawn themselves

#

a spawner should spawn things.

gray mural
#
private int Nice(int bla)
{
    bla += 1;

    return Nice(bla);
}
heady iris
#

recursion, broadly, is any time something triggers itself

#

this is recursion

urban marsh
#

Recursion is recursion

potent sleet
#

you keep clicking it and keeps showing it

heady iris
#

small giggle

potent sleet
gray mural
potent sleet
#

yup

heady iris
#

looks fine to me.

potent sleet
#

nah

#

now they fixed it

thick socket
#

Is there a method to just grab a random location inside of the biggest circle?
the circle is a collider(trigger)

heady iris
#

ah

gray mural
heady iris
#

i was finding your post 😛

potent sleet
#

xD

heady iris
#

i was searching for "Annular"

potent sleet
#

haha

#

anular

thick socket
#

ah, I can just grab the colliders radius and use that 😄

#

thx

#

Is that a bad way to do a "radius" for like a mob spawner?

potent sleet
#

why would it be bad ?

thick socket
#

figure having a way to visually see the radius is good

thick socket
gray mural
heady iris
heady iris
#

rejection sampling!

#

noooo you can't just uniformly sample points until you find a good one, you have to do complex math! noooooo!

#

haha rectangle go brr

thick socket
heady iris
#

No. Editor gizmos appear in the scene view.

thick socket
#

Good to know thx

heady iris
#

I mean, they can appear in the game view, too, if you turn on gizmos

#

i believe they don't show up in the built game

potent sleet
#

yup gizmos is editor only

thick socket
#

Makes sense, Ive used it before but had to click play to see the gismos...maybe I was using them wrong lol

potent sleet
#

you prob were using the Debug.Draw functions

thick socket
#

Ah yeah you are right

heady iris
#

I bet they still work in editor scripts

#

but yeah, your code was only running in play mode

#

Gizmos are a little different. They're drawn in specific functions

potent sleet
#

i think they both call DrawLine_Injected
interesting call to C++ I guess for both

#

private static extern void DrawLine_Injected (ref Vector3 from, ref Vector3 to);

heady iris
#

passing vector3s by ref. wacky!

quartz folio
potent sleet
#

noice!
bookmark this

heady iris
#

neat

thick socket
#

woah

#

refreshing on CTRL+R only works in 2021.3 unity

#

must be nice 😦

heady iris
#

ah, it was added then?

#

it shouldn't really be necessary if unity is correctly noticing file changes

cobalt apex
#

Has anyone ever encountered the issue where OnPointerDown event does not trigger while the timescale of the game is 0, but only if the gameObject was instantiated while the timescale is 0? If the timescale goes back to normal and then back to 0, the event still works. If so, has anyone any pointers as to how I could still register the OnPointerDown event for a gameObject while it is instantiated in timescale 0, and the timescale is still 0 when trying to press it?

jaunty sleet
#

Does anyone know if it is possible to get the coroutine from inside of itself? Like a "this" keyword but for coroutines

buoyant crane
#

what’s the use case?

jaunty sleet
#

Because I want to assign a coroutine that is being called from another script to a coroutine variable inside of its own script

#

and I don't want to have to have a coroutine property with a public set

buoyant crane
jaunty sleet
#

It can be assigned like that but that means in my use case every time I want to call it, which it is only called from another script, I have to assign it to a property from it's home script

#

I can do it that way I was just wondering if there is a better way, like assigning the coroutine to a coroutine variable from inside of itself when it starts running somehow

knotty sun
#

Coroutine cor = StartCoroutine(MyMethod(cor));

jaunty sleet
#

oh, I could pass it in as a parameter

#

that's a good idea

#

Now I don't have to have another public member of my script for no good reason. Thanks

sage latch
#

I read this article about dependency injection, wondering if I should implement it yourself. The way he implements it is having a dependency context MonoBehaviour inject its children and also putting itself in DontDestroyOnLoad. Is that really the best way to do it? Isn't the point of DI to have any class be able to access dependencies to replace singletons, not just children of a DDOL manager??

thick socket
#
yield return new WaitUntil(() => activeEnemies.Count == 0);

How often will this code check this? Is this bad to use inside a coroutine if many objects will have it?

heady iris
#

it's checked twice per frame, iirc

#

around Update and LateUpdate

#

you'd find that if you checked the docs :p

thick socket
#

oh yeah

#

out of the loop thanks 😄

buoyant crane
thick socket
#

gotcha

#

I'll probably just cause the check to happen every 0.5s instead 🙂

sage latch
#

Is the count check expensive at all though?

potent sleet
#

define expensive?

thick socket
#

the check itself is just checking the count of a list

#

however the fact that its checking once every frame is bad right?

buoyant crane
sage latch
#

How much better is a WaitForSeconds?

heady iris
#

computers can do a LOT of work

buoyant crane
#

but it’s an easy optimization. Especially with lots of enemies

potent sleet
sage latch
#

Doesn't it check the time atleast once a frame?

thick socket
#

so can't really use 1 coroutine to check for all

buoyant crane
#

ah i see, so they all have different ones

thick socket
#

yep

thick socket
#

would have expected the WaitForSeconds to be much better, now Im not sure at all lol

sage latch
#

You should at least cache it, to avoid creating a new WaitForSeconds each time

heady iris
#

you can, indeed, re-use the same instance many times

knotty sun
sage latch
thick socket
sage latch
#

Caching the WaitUntil shouldn't be neccessary, but it would be

readonly WaitUntil EnemyCountWait = new WaitUntil(() => activeEnemies.Count==0);
thick socket
gray mural
#

I have copypasted the full code from TMP_InputField to another script and renamed TMP_InputField class to CustomInputField.
But in the Inspector some components are missing and also shifted a bit.

thick socket
#

but also...

knotty sun
#

dangerous to cache a WaitUnitl, WaitForSeconds however is a different matter

sage latch
#

(inside the method)

#

which defeats the purpose of caching it

thick socket
#

not sure if Im overthinking it 😄

knotty sun
#

worse

sage latch
#

I think the difference is extremely small

knotty sun
#

but yes, you are overthinking

thick socket
#

fair enough

thick socket
# knotty sun dangerous to cache a WaitUnitl, WaitForSeconds however is a different matter

Why is caching a WaitUntil bad?

    private List<GameObject> activeEnemies = new List<GameObject>(); // List to track active enemies
    private WaitUntil allEnemiesDestroyed;

    // Start is called before the first frame update
    void Start()
    {
        allEnemiesDestroyed = new WaitUntil(() => activeEnemies.Count == 0);
        StartCoroutine(spawnEnemy(ghostSpawnRate, ghostPrefab));
    }
#

seems like it would work nicely

sage latch
#

It only uses one WaitUntil per coroutine

#

So if you're only running it once, the caching does nothing

manic maple
#

hello! i'm new here

knotty sun
#

activeEnemies is, in this case a class varaible. generally with WaitUntil you would require a local variable

thick socket
knotty sun
#

but it gains you nothing by doing so

thick socket
#

figure it prevents a new one from being created every frame?

#

thus saving at least a little performance?

knotty sun
#

no, not the way it works

#

the waitUntil is created once, it is evaluated every frame

thick socket
#

interesting

#

I wonder why WaitForSeconds is different then

#

sounds like Unity is just caching the waitUntil itself

knotty sun
#

because it can easily be shared between many coroutines

thick socket
#

I understand like 70% of that lol...but good enough for me 😄

#

no need to cache waitUntil, but do cache WaitForSeconds 🙂

knotty sun
#

this is created once

WaitUntil(() => activeEnemies.Count == 0);

this is evaluated once per frame

() => activeEnemies.Count == 0;
thick socket
#

But the above where its cached isn't better than this?

yield return new WaitUntil(() => activeEnemies.Count == 0);
knotty sun
#

not as you used it, no

thick socket
#

gotcha thanks 🙂

knotty sun
#

if your startcoroutine was in a for loop for example then caching the waituntil would make sense

thick socket
#

So if I was in a while(true) loop like this caching it is good right

private IEnumerator SpawnEnemy(float interval, GameObject enemy)
    {
        while (true)
        {
            // Check if the maximum number of enemies has been reached
            if (spawnedEnemies >= maxEnemies)
            {
                // Wait until all active enemies are destroyed
                yield return new WaitUntil(() => activeEnemies.Count == 0);

                // Reset the counter
                spawnedEnemies = 0;
            }

            yield return new WaitForSeconds(interval);
            GameObject spawnedEnemy = Instantiate(enemy, new Vector3(Random.Range(-spawnSquare, spawnSquare) + transform.position.x, Random.Range(-spawnSquare, spawnSquare) + transform.position.y, 0), Quaternion.identity);

            // Add the spawned enemy to the active enemies list
            activeEnemies.Add(spawnedEnemy);
            spawnedEnemies++;
            spawnedEnemy.GetComponent<EnemyController>().OnEnemyDestroyed += RemoveEnemyFromList;
        }
    }
knotty sun
#

yes, that would be a very minor improvement

thick socket
#

but overall WaitUntil and WaitForSeconds improvement is small enough I can do whichever I prefer as well

knotty sun
#

exactly

#

it's like any lanbda code, better not used in loops

thick socket
#

had thought that caching things like WaitForSeconds and WaitUntil would be mediocre improvements always worth doing 😄

knotty sun
#

again it depends how often they are being called, like everything else. No need to optimise to the nth degree something which is only being executed once

thick socket
#

Makes sense to me, Thanks for all the help!

knotty sun
#

np, good to see you are at least thinking about these things because they do matter

thick socket
#

out of curiousity...do you have a link to the stuff you have put on the unity store? notice that I can't find a "SteveSmith" by looking it up 😄

knotty sun
thick socket
#

cool thanks!

#

weird that SteveSmith doesn't come up lol

knotty sun
#

Unity hate me

knotty sun
jaunty sleet
#

Does anyone know what happens to a coroutine value when the coroutine it represents stops running?

knotty sun
#

nothing

jaunty sleet
#

Like if I say Coroutine c = StartCoroutine(coroutine()); What is the value of c when coroutine() stops running on its own?

knotty sun
#

the value given to it by the startcoroutine. not that you can do anything with it

jaunty sleet
#

Also what happens if I call StopCoroutine on c

knotty sun
#

depends if c is running

jaunty sleet
#

yeah, so what happens if I try to stop it and its not running?

knotty sun
#

pretty sure absolutely nothing

jaunty sleet
#

ok, thanks

normal stump
#

is there a lightweight queue I can use in update method?

#

I feel the C# queue is heavy, though idk really

heady iris
#

no idea what "heavy" means

#

or, more specifically

#

i'm not sure why it'd be "heavy"

normal stump
#

takes up a lot of cpu cycles to dequeue/check

heady iris
#

standard library data structures are pretty performant

#

don't try to prematurely optimize

normal stump
#

right

#

do you think it's ok to call the deqeueu in update?

late lion
#

If there's anything you need to worry about Queue, its allocation when creating it and when enqueuing many items.

heady iris
#

your computer's CPU is screaming along at billions of cycles per second

#

you can remove an item from a queue

#

don't think about it.

normal stump
#

ok

normal stump
#

they contain game objects and some parameters, like a vec3

fervent furnace
steady moat
#

Given that the capacity is not exceeded.

late lion
#

dequeue

steady moat
#

Oh, yeah my bad.

#

I was reading enqueue at the same time.

If Count already equals the capacity, the capacity of the Queue<T> is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

If Count is less than the capacity of the internal array, this method is an O(1) operation. If the internal array needs to be reallocated to accommodate the new element, this method becomes an O(n) operation, where n is Count.

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1.enqueue?source=recommendations&view=net-7.0

normal stump
#

I use TryDequeue

#

and I want my capacity to be very high, so not putting a limit should be fine

steady moat
#

You want to put a capacity before hand to reduce the amount of time you reallocate memory.

fervent furnace
#

generally for allocation strategy of doubling the size, the avaerage time of adding one element is O(1)

heady iris
#

if you want to absolutely wring out every last bit of performance, then you want to preemptively give the queue a high enough capacity

steady moat
#

Capacity is the initial allocation.

heady iris
#

of course, this probably doesn't matter at all

normal stump
#

right

#

this is also server side code

#

tickrate will be around 30-45

#

so I think it will have ample time to dequeue

#

and do gc at the same time

steady moat
#

Your issue will most likely NOT be a queue if you ever have one.

heady iris
#

write the code normally, then profile it if you need to

normal stump
#

yeah I will

fervent furnace
#

you can set the initial capacity to be a power of 2 so that each % will be turned into & operation (i remember the initial capacity is 4)
i sometime do this

normal stump
#

well come to think about it

#

I think the max capacity will be around 40 under load

fervent furnace
#

then set it to 64

cold parrot
#

How many of those queues are you creating every frame?

normal stump
#

created once per script

fervent furnace
#

%power of 2 is equivalent to & power of 2 -1
but these optimization will be handled by compiler

normal stump
#

if need be

cold parrot
#

Then why are you even talking about optimization? This is a total waste of time.

normal stump
#

I was asking if dequeuing was an expensive operation

cold parrot
#

it’s practically free, that’s the whole point of a queue

normal stump
#

👍

fervent furnace
#

i dont know, but for compile time const the compiler is supposed to generate bitwise and if the queue size is power of 2

heady iris
#

all of this is going to be a rounding error in the grand scheme of things

normal stump
#

yup

native fable
#

why does he write that there are 6 triangles if there are 2 triangles in the quad?

solemn raven
#

hi,
is there is a way to replace something within a text file after reading it ?

example
txt file , Name txtFile.txt

var x = [X];

is it possible to read the file using string[] lines = File.ReadAllLines(filepath);
then somehow search for all [X] and replace it with 10; ?

hexed pecan
#

So each item in triangles is actually 1/3 of a triangle

fervent furnace
native fable
hexed pecan
#

No they are not XYZ coordinates

#

They are indices for the vertices array which contains the coordinates

native fable
#

aaa of course

zinc citrus
#

How i can disable the AR Plane that its placed ? i use ```cs
plane.requestedDetectionMode = UnityEngine.XR.ARSubsystems.PlaneDetectionMode.None;

native fable
#
private void SubdivideMesh()
    {
        MeshFilter meshFilter = GetComponent<MeshFilter>();
        Mesh originalMesh = meshFilter.sharedMesh;
        Vector3[] originalVertices = originalMesh.vertices;
        int[] originalTriangles = originalMesh.triangles;

        Vector3[] newVertices = new Vector3[originalVertices.Length + (originalTriangles.Length / 3) * 3];
        int[] newTriangles = new int[originalTriangles.Length * 4];

        for (int i = 0; i < originalTriangles.Length; i += 3)
        {
            int vertIndexA = originalTriangles[i];
            int vertIndexB = originalTriangles[i + 1];
            int vertIndexC = originalTriangles[i + 2];
            Vector3 vertexA = originalVertices[vertIndexA];
            Vector3 vertexB = originalVertices[vertIndexB];
            Vector3 vertexC = originalVertices[vertIndexC];
            int newVertIndex = i * 4;
            newVertices[newVertIndex] = vertexA;
            newVertices[newVertIndex + 1] = vertexB;
            newVertices[newVertIndex + 2] = vertexC;
            newVertices[newVertIndex + 3] = (vertexA + vertexB + vertexC) / 3f;
            newTriangles[i * 4] = newVertIndex;
            newTriangles[i * 4 + 1] = newVertIndex + 1;
            newTriangles[i * 4 + 2] = newVertIndex + 3;
            newTriangles[i * 4 + 3] = newVertIndex + 1;
            newTriangles[i * 4 + 4] = newVertIndex + 2;
            newTriangles[i * 4 + 5] = newVertIndex + 3;
            newTriangles[i * 4 + 6] = newVertIndex + 2;
            newTriangles[i * 4 + 7] = newVertIndex;
            newTriangles[i * 4 + 8] = newVertIndex + 3;
            newTriangles[i * 4 + 9] = newVertIndex;
            newTriangles[i * 4 + 10] = newVertIndex + 2;
            newTriangles[i * 4 + 11] = newVertIndex + 1;
        }
        Mesh subdividedMesh = new Mesh();
        subdividedMesh.vertices = newVertices;
        subdividedMesh.triangles = newTriangles;
        meshFilter.sharedMesh = subdividedMesh;
    }
#

why this code not change my mesh in mesh filter?

knotty sun
native fable
knotty sun
#

yes, I know

native fable
#

hmm

knotty sun
#

sharedMesh and mesh are 2 different things. Read the docs

native fable
# knotty sun sharedMesh and mesh are 2 different things. Read the docs

The SharedMesh property refers to your actual mesh asset, so changes to the mesh will affect all objects that use that mesh reference, and (I think) changes will apply to the mesh asset in your asset folder with running in-editor.

The Mesh property will apply to the "mesh instance" created for this specific object. The first time you access the "mesh" on an object, a new copy of the mesh will be created for you to modify. All additional times you access the "mesh" on the same object, you will get the same mesh that was created for you the first time you tried to access the "mesh" on this object. Since each object has it's own instance, edits will only apply to the one object.

Yes, i Read this, but with sharedMesh should also work

native fable
glossy cobalt
#

heya, im learning tilemaps with composite colliders, previously I had seperate gameobjects for every floor and wall.

I'm running into a problem where my character's Y velocity is never zero when it is on the tilemap floor, which is important for other code I have written. this problem is fixed when i set the tilemap's rigidbody2D to dynamic, but i'm assuming that's bad practice for stationary platforms. I didn't have this problem when I used individual gameobjects set to static. could I have some help?

median cairn
#

Hey Guys, I have a Question !
I did this code that is supposed to check if it is a single tap or a swipe but it doesn't work. Could you help me ? ```
private void Start()
{
touchControl.Earth.EarthX.started += UpdateRotation;
touchControl.Earth.EarthClick.started += OnClickStarted;
touchControl.Earth.EarthClick.performed += OnClickPerformed;
}

private void UpdateRotation(InputAction.CallbackContext context)
{
    Debug.Log("Swipe");
    float earthXValue = context.ReadValue<float>();
    float rotationAmount = earthXValue * rotationSpeed * Time.deltaTime;
    transform.Rotate(0f, 0f, -rotationAmount);
}

private void OnClickStarted(InputAction.CallbackContext context)
{
    clickStartPosition = context.ReadValue<Vector2>();
}

private void OnClickPerformed(InputAction.CallbackContext context)
{
    Vector2 clickEndPosition = context.ReadValue<Vector2>();
    touchControl.Earth.EarthClick.performed -= OnClickPerformed;
    Debug.Log("test");

    if (Vector2.Distance(clickStartPosition, clickEndPosition) <= clickPositionThreshold)
    {
        Debug.Log("Tap");
    }
}

}```

karmic crown
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

tiny reef
#

Im trying to make like a 2d sandbox and there are different types of Tiles like Stone and Dirt each represented by their own class extending a Tile class
what would be the best way to replace a Tile? i have like 2 methods for Deleting a Tile and placing a new one
but when replacing a Tile i could get away without deleting and creating a new GameObecjt, right?

fervent furnace
tiny reef
#

ill have a look thx

hexed oak
#

Got a weird bug with some gameobjects not invoking their OnMouseDown's when I change to a different camera. For context, I have 2 cameras, one renders a minigame, which turns off the main camera and enables the minigame cam until the minigame is over. Then the main cam is enabled again, but gameobjects within the main cam can't be clicked on unless (discovered this) I enable and then re-disable either one of the cameras

#

I troubleshot so far as to disable everything inside the minigame besides the camera, and it still happens

#

I don't understand why enabling/disabling a camera would make the gameobject clickable again. I'm literally not changing anything--so it must be something Unity does under the hood that causes this

leaden ice
#

It'd be better to use the newer, more documented and more flexible IPointerDownHandler

#

which will depend on which camera has an active PhysicsRaycaster

heady iris
#

i was wondering about that

hexed oak
#

These are normal gameobjects with normal transforms, not UI elements with a rect transform on a canvas

leaden ice
#

The only difference between doing this with UI and game world objects is which Raycaster

#

GraphicRaycaster on the canvas for UI

#

PhysicsRaycaster (2D) on the camera for game world colliders

hexed oak
#

Ok, I created a new scene and attached physics2DRaycaster to the camera. Added an event system and a test script that implements IPointerDownHandler, IPointerEnterHandler, IPointerUpHandler, and it won't detect a touch on the box collider 2D in the scene.

leaden ice
hexed oak
#

My test script that implements the handlers is attached to the same gameobject that has the box collider 2D

#

event system is attached to a separate empty gameobject

#

I've never gotten those handlers to work without a canvas

#

I'd be delighted if it was possible

leaden ice
#

This is indeed the whole point of the physics raycasters

#

which wouldn't exist if it were not possible

#

is the camera and/or gameobject that has the raycaster enabled too?

hexed oak
#

YOU SOLVED IT

#

I forgot to Add Default Input Modules

tired drift
#

Hi hi! I'm having some problems with Newtonsoft. Currently it is serializing the data just fine, but deserialization is giving me some issues (that didn't happen before tbh).

So it says Unable to find a constructor to use for type Core.Survivor.SurvivorData

thing is it does have one:

namespace Core.Data
{
    [Serializable]
    internal class SurvivorData
    {
        [JsonProperty] public List<Survivor.SurvivorData> survivors = new List<Survivor.SurvivorData>();
        [JsonProperty] public List<Vector3> survivorsPos = new List<Vector3>();

        [JsonConstructor] public SurvivorData() {}
        //[JsonProperty] public Dictionary<Survivor.SurvivorData, Vector3> survivors = new Dictionary<Survivor.SurvivorData, Vector3> ();
    }
}```

any idea what's going on? ![screamcat](https://cdn.discordapp.com/emojis/668299950647410688.webp?size=128 "screamcat")
swift falcon
swift falcon
tired drift
swift falcon
#

oh, right

#

hmm

#

maybe it requires a constructor with a certain set of arguments? but the error for that should be different iirc

tired drift
#

shouldn't be an issue. The class handling this data also has a default constructor and is populated with the deserialization. For some reason it isn't liking this class too much

leaden ice
#

different class entirely

tired drift
#

f didn't notice it

#

you're right

leaden ice
#

Kinda confusing that you have those two classes with the same names AND this one contains a list of the other one 😵‍💫

tired drift
leaden ice
#

the fix is to give it one

tired drift
#

it does have a constructor i think i forgot to pass the attribute on it, but even so it won't work the way i want possibly, maybe i'll have to do some changes

leaden ice
#

not one that Newtonsoft can use, is the thing

tired drift
#

yeah the attribute does wipe the error

leaden ice
#

but yes you might have to refactor some things

tired drift
#

actually worked without a refactor

lean sail
#

isnt it an issue too that its internal or no?

tired drift
#

nah, that has to do with access levels based on being under a namespace

#

you can have a private class and deserialize into it as long as whatever you're deserializing to is public and matching names afaik

#

you can say internal = public, but internal is only visible inside the same assembly, plus namespaced classes are by default internal, which are public. Shrug it's just small nuances

#

correct me if i'm wrong tho screamcat

leaden ice
#

classes are only internal if they're marked as such. The default access modifier is private

tired drift
lean sail
#

but if its not the issue then disregard

leaden ice
tired drift
earnest gazelle
#

Have you faced situations where you define attributes (Attribute type) for each attribute of a scriptable object instead of defining primitive types like int Power, int maxHealth?
I mean wrap attributes inside Attribute type, encapsulate it.

  public class AttributeDefinition : ScriptableObject
    {
        public string Name;
        public Sprite Icon;
    }

    public abstract class Attribute
    {
        public AttributeDefinition Definition;
        public abstract string StringValue { get; }
    }

    [Serializable]
    public class Attribute<T> : Attribute
    {
        public T Value;
        public override string StringValue => Value.ToString();
    }

    [Serializable]
    public class FloatAttribute : Attribute<float>
    {
    }

    [Serializable]
    public class IntAttribute : Attribute<int>
    {
    }

    public abstract class Data : ScriptableObject
    {
        public abstract Attribute[] GetAttributes();
    }

    public class Data1 : Data
    {
        public IntAttribute Power;

        //...
        public override Attribute[] GetAttributes()
        {
        }
    }

    public class Data2 : Data    // Data1 and Data2 are completely different types
    {
        //...
        public IntAttribute Power;
        //...

        public override Attribute[] GetAttributes()
        {
            return new[] { Power };
        }
        //...
    }

The benefit is that you define an attribute only once (name + icon), then you can use it in different unrelated scriptable objects. Also, getting attribute info is easy to show them as stats.

or you prefer to define attributes of scriptable objects explicitely with primitive types and then inside UI classes, handle how they should be shown (probably different UI class for each),

 public class Data1 
    {
        public int Power;

        //...
    }
swift falcon
#

why is it when i use instantiate on a prefab, its position is always 0, 0, 0 no matter what?

lean sail
shut ridge
#

ty mods

#

anyway

#

how do you make a rotating rigidbody forcefully push another?

leaden ice
sacred vault
#

I use Vector3.SignedAngle()

#

blue line is the axis

#

but why it returns 50?

#

I don't understand

quartz folio
#

It's hard to tell what you are doing, it would be easier if you provided some code

sacred vault
#
        result = Vector3.SignedAngle(Vector3.down, transform.rotation * Vector3.down, transform.rotation * Vector3.forward);
#

I would replace transform rotation to gyro.attitude

quartz folio
#

Just a gotcha about SignedAngle:
Do not expect the "from" and "to" vectors to be flattened against the Axis when calculating the angle. If the inputs are pointing at all up or down in the plane defined by the axis, you're going to get the "Angle between two 3D vectors" returned. NOT the "Angle between two 3D vectors flattened on a plane".
Workaround: Make sure that you flatten the "from" and "to" vectors against the axis: i.e.

Vector3.SignedAngle(Vector3.ProjectOnNormal(from, Vector3.up), Vector3.ProjectOnNormal(to, Vector3.up), Vector3.up);
sacred vault
#

welp, someone needs to make this more clear then

quartz folio
#

Yeah, the axis only influences the sign, nothing else

sacred vault
#

Vector3.ProjectOnNormal doesn't exist for some reason

quartz folio
#

ProjectOnPlane will do it

sacred vault
#

oh ok

#

let's see

#

the X axis affects the sign of the result

#

found the problem

#

now it just affects the result

#

oh wait no

#

I rotated it locally in the scene view

#

it works perfectly now

#

thanks alot

hasty orchid
#

Using the Lobby Services, how can you get how many people are in the lobby?

hasty orchid
#

tyy!

fluid lily
#

!codebin

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

gaunt wren
#

I posted this on Reddit however I didn't get any responses so gonna post the link here with a summary. https://www.reddit.com/r/Unity3D/comments/13ulgis/portals_rendering_characters_advice/
I'm working with Sebastian Lague's code base for portals in my shooter and I'm unsure how to proceed with how to render the Player's third person model when viewed through a portal. In his codebase, a clone object of the players model is created to mimic the player moving through a portal seamlessly.

My issue is that when the Player clips into a portal partially, the 3rd person clone object gets rendered on the exit portal which can block the view in return ruins the seamless effect. I'm not asking for code but advice on how to tackle this issue as I'm probably overthinking it. The reddit post lists all the things I've considered/attempted so far however I'm unsure which is the best route to go unless I've missed a obvious one.

cosmic rain
#

Ah, I think I understand the purpose of rendering that model by your first person camera!

#

Or not.

#

Yeah, I guess I still don't understand why you'd need the third person model sticking to your first person camera.

gaunt wren
#

Just to clarify, In Portal, you can see the player character through portals. My setup, the first person camera doesn't render the player model however the portal camera do render the player model

elder kiln
#

Anyone great with tilemaps? My game uses 960x540 as the Pixel Perfect reference resolution, and I want my overworld tiles to be 60x60. By default that means my grid hangs half a tile out of screen, so I figured no problem, I'll just offset it 30 pixels. Unfortunately, now when I place a tile, it gets a 30 pixel offset, despite having {0,0} offset when I select it in the palette

gaunt wren
cosmic rain
# gaunt wren

I see. What if you offset the model back behind the fps camera a little bit?

gaunt wren
#

I'll give that a try. that could be the simple fix I overlooked

gaunt wren
#

doesn't work unfortunately. Offsetting the character moves the clone object out of the view on the otherside causing the player to be partially cut off. didn't find any middle ground with the offset. Thanks for the suggestion though

vocal root
#

What's better for damage particles, start a particle system inside the enemy or instantiate it on hit?

gaunt wren
#

Instantiate on hit would definitely be easier and the preferred option I imo. Since you are using particles, you could replicate the particles spawning from inside the mesh without needing to spawn them inside the mesh. What kind of damage is this? Bullets, melee damage?

civic fern
#

id assume, on hit no?

native fable
#

How to get all pixels from texture that used in my mesh triangles? I vant save this part pf texture as sprite

vocal root
maiden fractal
dim crypt
#

Checking if a non-http link is valid

Anyone know how to check if a link is valid in unity?

I know you can use:
Application.OpenURL(someLink);
but the problem is that doesn't return anything to tell you if the link is valid or not and give you a way to habdle what to do if it isn't valid

I made this little extension:
public static bool IsValidURL(this string source) => Uri.IsWellFormedUriString(source, UriKind.RelativeOrAbsolute);
and that works fine if you link starts with "https://" like this for example:
"https://www.google.co.za/"

But if I want to open a link in the browser that isn't an http link, like say for example a repository URL:
git@ssh.dev.azure.com:v3/SomeOrganization/SomeProjectProductName

The IsValidURL extension will return false because it's not an HTTP link

native fable
maiden fractal
# native fable only those that are rendered

That only makes it harder, a lot harder I think. What is the deal with all this? I think this is a xy problem at this point, theres probably better way to achieve the same thing

native fable
maiden fractal
native fable
maiden fractal
# native fable I write some code, but it work not correctly https://pastebin.com/7MT79YRg

Maybe your triangle rasterization is flawed in some way. If the processing speed is not a concern for you at this point, you could just take the bounding box of the triangle, loop through each pixel on the box and use algorithm copied from online to check whether the point is inside the triangle or not, just to make sure its not the scanline algorithm thats failing (scanline algorithm sounds fine, id use something like that myself too)

native fable
native fable
maiden fractal
native fable
maiden fractal
#

Just different way to rasterize the triangle

mossy snow
#

are you sure you aren't overcomplicating this? If you're just trying to capture what the mesh looks like into a texture, why not set up a camera + RT, render mesh, then just read pixels straight back? Pixel-by-pixel rasteration looks crazy. The other simple thing you might try is to literally create a sprite and copy the mesh data to it, UVs and all, and save that as an asset. I haven't tried that, but I assume it would work too

native fable
mossy snow
#

you said it was editor only, so why does that matter? Create the sprite as an asset

native fable
native fable
tiny reef
maiden fractal
# native fable )))

Seems quite blocky, I dont think you succeeded in implemententing that algorithm either. Could you share the cirrent code?

#

At least it looks different so either of them or most likely both has to be incorrect

native fable
maiden fractal
# native fable https://pastebin.com/69cPwYbE

Seems alright to me. Maybe you should start debugging the code by first drawing only one triangle, maybe coloring each corner (pixelX0, pixelY0), (pixelX1, pixelY1) and (pixelX2, pixelY2) with lets say blue (after the drawing is done so they doesnt get drawn on top) and compare the corners with the wireframe image to find out whether that triangle even exist there (so the pixel coordinates of the vertices are right). Then you can look whether the drawn triangle matches the corners etc.

#

When you find what exactly isnt working, you should be able to fix the problem, more easily atleast

vocal root
#

How do you usually check for the first time the player does something? For example a unique cinematic that only happens one time. A bool in a Scriptable Object?

fervent furnace
#

@tiny reef you can place tile in run time, but if you need to store data in tile, you need scriptable tile and i am not familiar with this

tiny reef
#

hm yeah im currently trying out the object pool but ill sea if that makes sense

#

the thing is i have like 10 and in the future way way more types of tiles

#

so im not sure how an object pool would work in that case

#

because every tile is like its own prefab with own script

latent latch
fervent furnace
#

for each type of tile you can create a object pool of it and pick it in object pool to avoid massive calls of destroy()

tiny reef
#

does it matter how many tiles i create in each pool?

#

because its only once so more shouldnt really matter that much, right?

latent latch
#

you can always dynamically adjust your pool, but that requires some extra work

fervent furnace
#

instantiate more objects only when the pool is empty

latent latch
#

if you know you're going to use certain amount of prefabs, just cache a few thousand or two

tiny reef
#

yeah its like a few ten thousand

#

but that should not be a problem with pools anymore

#

i mean im planning on doing chunks so there will be a maximum amounts of tiles at any time

latent latch
#

yeah chunks is ideal

#

mixed with some asynchronous methods

tiny reef
#

yeah i can just instantiate the maximum amount of possible tiles for every pool

vocal root
latent latch
#

If you have a single character, who doesn't say share mechanics with your enemies (can implement around this idea easily), that sounds fine

#

Not likely to fall into the spagetti problems of singletons that easily, unless you've planning on a large scope of a project.

vocal root
normal sedge
#

if you want to slow down time would using Time.timeScale = 0.5 be the right way to do it? when this happens the whole slow motion just feels like low fps and not smooth slow motion

hexed pecan
knotty venture
#

i am very very dumb

#

it was on something that i have never seen i am very very sorry

latent latch
manic charm
#

Hello everyone, I ran into a problem with AR zoom on android. I made a couple of scripts, but they don't work on android, however, everything is stable when testing the scene. Can you help me with writing the AR zoom script

#

However, if you have working scripts in the stack, I will be very grateful if you share them

vocal root
#

ok im going crazy with this.
I have this code

bool hasHit = Physics.Linecast(startSlicePoint.position, endSlicePoint.position, out RaycastHit hit, sliceableLayer);
        if(weaponSpeed >= 200)
        {
            if(hasHit)
                {
            
                    GameObject target = hit.transform.gameObject;

It is supposed to make "target" variable into the gameobject that has the scliceableLayer, and that worked till yesterday when I went to sleep, but now I open the project again and now what it does is to make "target" into the parent of the gameobject it hits with the raycast

leaden ice
vocal root
#

havent touched anything, just opened the project to see a thing

native fable
late lion
#

You just need to replace the Graphics.Blit with a Graphics.DrawMeshNow with the mesh of the sprite.

native fable
leaden ice
#

Or are just misremembering

native fable
normal stump
#

hey, how do I get the terrain reference from a prefab? I'm trying to raycast from the cursor onto the terrain plane in order to get the cursor position on the terrain

leaden ice
normal stump
#

well the script is in a prefab

#

I need to get the ref from that script

queen tulip
#

my background looks fine in the editor, but in the running game some parts of it becomes like that (the first image)

im sure its got to do something with the code i made for the background to move so posting this here, can anyone help?

late lion
mystic yoke
native fable
queen tulip
mystic yoke
#

I'm guessing you're planning uvs?

#

Panning*

native fable
mystic yoke
#

Is it a cloud texture in the background?

queen tulip
mystic yoke
#

Your texture is set to clamp mode

#

Switch to repeat

queen tulip
jaunty hare
#

Hi, in a situation where we have 2 scenes loaded, is it possible de parent an object from the scene 1 to an object in the scene 2 ?

native fable
jaunty hare
native fable
jaunty hare
#

no error, no parenting

steady moat
mystic yoke
native fable
jaunty hare
mystic yoke
native fable
mystic yoke
#

Yes

steady moat
native fable
# mystic yoke Yes

I don’t understand a little, but how will DrawMeshNow draw an image on RenderTexture?

mystic yoke
jaunty hare
native fable
mystic yoke
native fable
jaunty hare
steady moat
mystic yoke
steady moat
native fable
jaunty hare
#

It works ! I just haven't seen some problems in my code

#

thanks guys :)

native fable
#

what am I doing wrong

native fable
#
[Button]
    public void MeshToSpriteV3()
    {
        Texture2D texture = meshRenderer.material.mainTexture as Texture2D;
        Texture2D spriteTexture = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);
        
        var duplicateTexture = GetRenderTextureWithMesh(texture);
        
        RenderTexture previous = RenderTexture.active;
        RenderTexture.active = duplicateTexture;
        Graphics.SetRenderTarget(duplicateTexture);
        
        spriteTexture.ReadPixels(new Rect(0, 0, duplicateTexture.width, duplicateTexture.height), 0, 0);
        spriteTexture.Apply();
        
        byte[] spriteData = spriteTexture.EncodeToPNG();
        File.WriteAllBytes(savePath, spriteData);
        
        RenderTexture.active = previous;
        RenderTexture.ReleaseTemporary(duplicateTexture);
    }

    RenderTexture GetRenderTextureWithMesh(Texture2D source)
    {
        RenderTexture renderTex = RenderTexture.GetTemporary(
            source.width,
            source.height,
            0,
            RenderTextureFormat.Default,
            RenderTextureReadWrite.Linear);

        // Graphics.Blit(source, renderTex);
        RenderTexture previous = RenderTexture.active;
        RenderTexture.active = renderTex;
        Graphics.SetRenderTarget(renderTex);
        
        Graphics.DrawMeshNow(MeshFilter.mesh, Vector3.zero, Quaternion.identity);
        
        RenderTexture.active = previous;
        RenderTexture.ReleaseTemporary(renderTex);
        return renderTex;
    }
balmy radish
#

so i have a problem.

public class PointController : MonoBehaviour
{
private void OnCollisionEnter(Collision collision)
{
Debug.Log("HII");
}
private void OnCollisionStay(Collision collision)
{
Debug.Log("BRO");
}
}

GameObject objec = Instantiate(gameObject,Vector3.zero, Quaternion.identity);

So i Instantiate 2 objects and they collide but i donot get any of those Debugs??
I have a collider on my prefab so anyreason why=

#

?

mellow sigil
#

Show the other object

balmy radish
#

it is like in for loop the 2 objects gets Instantiated

late lion
# native fable ```cs [Button] public void MeshToSpriteV3() { Texture2D texture ...

You're missing the part where you set the camera projection. This can be done through GL. The specific matrix you need will depend on the size of the Mesh you're drawing. The the vertices are in pixel-space, as in each vertex's position is the same as the pixel coordinate it would be on the texture, you can use GL.LoadPixelMatrix(). Otherwise, you will have to create an orthographic projection using Matrix4x4.Ortho that matches the size of the mesh.

mellow sigil
#

Then they're missing a rigidbody

balmy radish
#

oh wait

#

lol True but why do i need a rigidbody

#

if i am only working with collisions tho :/

mellow sigil
#

Rigidbody is the thing that collides

balmy radish
#

ohhh i got it

#

thx ^^

native fable
late lion
late lion
#

The local bounds of it, sure

native fable
late lion
#

Do you know where this mesh comes from? Did you generate it?

native fable
late lion
#

Cut from an atlas of other sprites, you mean?

native fable
late lion
# native fable

And the asset only generates the mesh, while using the original sprite texture?

native fable
#

and now I want to save the piece as a texture to disk.

late lion
# native fable yes, as seen in the screenshots above. under the hood, it uses a polygon collide...

Ok, so then I would try a basic orthographic projection. There will probably be some trial and error to find the right size so it matches up, but when it does, it should be a perfect copy of just the mesh part.

That would look like this in your method:

...
Graphics.SetRenderTarget(renderTex);

GL.PushMatrix(); // to save the previously loaded matrix
GL.LoadOrtho(); // load a basic orthographic projection

material.SetPass(0); // load the material to render the mesh with. This should be a basic sprite/unlit material with the right texture assigned.

Graphics.DrawMeshNow(MeshFilter.mesh, Vector3.zero, Quaternion.identity);

GL.PopMatrix(); // restore the previous matrix
...
#

You were also missing the material.SetPass(0), I thought that was a parameter in DrawMeshNow.

#

It also wouldn't be a bad idea to call GL.Clear(true, true, Color.clear); after Graphics.SetRenderTarget, in case you get a texture with old data in it.

knotty venture
#

i can't get my bullet to go forwards anyone out there to help me this is my code


public class Bullet : MonoBehaviour
{
    public float speed = 10f;
    public int damage = 1;

    private Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        rb.velocity = transform.forward * speed;
    }

    void OnCollisionEnter(Collision collision)
    {
        // Check if the bullet collides with an object with a health component
        Health health = collision.gameObject.GetComponent<Health>();
        if (health != null)
        {
            // Deal damage to the object
            health.TakeDamage(damage);
        }

        // Destroy the bullet upon collision with any object
        Destroy(gameObject);
    }
}
steady moat
knotty venture
#

yea

#

it is there and going the right way

steady moat
#

Also, arent they just destroyed on spawn ?

knotty venture
#

it just does not move forwards

steady moat
#

It does not move at all no ?

knotty venture
#

it does not move at all

#

i have tried collision off and it still does not move

steady moat
#

Probably because they are destroyed on spawn

knotty venture
#

well no

#

i had kemetic on

#

and it stays there

#

but touched is destroed

#

destroyed

steady moat
#

I mean, in your video they disappear.

knotty venture
#

yea

#

true

steady moat
#

THen, start by fixing that.

native fable
#

Ok so then I would try a basic

knotty venture
#

but the wont move if it wasn't the case

#

i have try alot of things man chatgbt can't even help me

steady moat
knotty venture
#

anyone that can help me with this ur a legend :))

finite coral
#

is it possible to bake a navmesh on runtime??

steady moat
# finite coral is it possible to bake a navmesh on runtime??
Unity Learn

In this recorded live training session we show how to work with Unity’s Navigation tools at runtime. We will explore the publicly available Components for Runtime NavMesh Building and look at how we can use the provided components to create characters which can navigate dynamic environments and walk on arbitrarily rotated surfaces, including ene...

maiden fractal
#

Finding the issue is always the first step on solving it

whole dawn
#

Which is better ?

static matrix
#

is it possible to Task.Run a function (I can change the return) that I need parameters for

#

because its causing random lag spikes, which it wasn't doing before, which is wierd
so I thought I could run it asynchronously to avoid slowing the game

granite nimbus
#

how do I trigger domain reload through code?

granite nimbus
steady moat
#

Domain reload is whenever script are being invalidate ? Which happens if you recompile ?

#

I can be wrong though.

granite nimbus
#

well I have no idea. I'm just curious

steady moat
#

Why would you want to reload the domain ?

granite nimbus
#

there's 0 info online on domain reload besides brief explanation of what it is and how to disable it

granite nimbus
steady moat
granite nimbus
#

still same errors

steady moat
#

What is the error ?

#

I've deleted a lot of objects through unity editor code and never had an issue.