#archived-code-general
1 messages ยท Page 417 of 1
in ANY way
IProcedure derives from IListenable and ProcedurePointsblabla derives from IProcedure
I think the most reasonable option here is to just store a Delegate. You can cast these back into the correct type when they're used.
this assumes I give up and my AddListener looks like this
I tried just now, and invoking them is a pain due to them having different amount of arguments
That will still be necessary.
https://paste.myst.rs/8yu6j0r9
you might find this to be useful; it's a memoizer I use to make exactly one copy of an object for a given set of arguments
I got around the variable-argument problem by just using value tuples
okay I can try with the Delegates again...
(they aren't mandatory, but the type names hint at what I intend the user to do)
((the user being me))
I find this to be pretty tolerable. Let me find an example of using it
return Memoizer.Memoize(
(data, entity, state, target, moduleTarget),
static t => new ModuleTargetedStateActivity(t.data, t.entity, t.state, t.target, t.moduleTarget));
Mildly silly
C# does not support variadic generic types, so you run into a wall there
I feel like I could codegen this
oh god I think I'm too tired to get this. It's almost 1am here...
I rephrase any constructor as a one-argument function that takes a value tuple
not a clue what this does I think I'll try with those delegates and worst case scenario I'll have the Action<IListenable> and have a bit of boilerplate
I once did an event dispatcher for tfs2 in sbox. This had a class for each event with its "args" defined in there: e.g.
public class PlayerSpawnEvent : DispatchableEventBase
{
public IClient Client { get; set; }
public TFTeam Team { get; set; }
public PlayerClass Class { get; set; }
}
You subscribed with: public static void Subscribe<T>(Action<T> callback, object sourceTarget = null, bool once = false) where T : DispatchableEventBase
This worked decently as on subscription we did this:
//A lambda needs to wrap the provided callback so we can cast the argument and successfully add the subscription.
EventDelegate eventDelegate = ( args ) => callback( (T)args );
//Make event subscription struct to store the casted delegate call, the original and the target entity.
EventSubscription subscription = new( eventDelegate, callback, sourceTarget );
EventSubscription was then stored to invoke later.
if it's this easy I'll be annoyed
I cannot possibly explain how much that isn't a concern in comparison to all other options XD
god is it really that easy?
Actually, I'm pretty sure you can avoid an allocation
goddamnit
Hey its what i came to like 2 years ago ๐
This anonymous function doesn't capture anything
would turning it to a local function avoid allocation?
because rider is suggesting that
What happens if you add static before (listenable)?
oh, duh, it's capturing listener there
You'd have to resolve it into an object to put it in a list, and that would allocate
this is a very useful rider extension
whatever, I'm not doing this often, I can have a small alocation there
yeah
i dont see the concern unless subscriptions/unsubs are done frequently
this seems sufficient to me though
private Dictionary<Type, List<Delegate>> map;
public void AddListener<T>(Action<T> action)
{
Type type = typeof(T);
if (!map.TryGetValue(type, out var list))
{
list = new();
map[type] = list;
}
list.Add(action);
}
public void ExecuteListener<T>(T arg)
{
Type type = typeof(T);
if (!map.TryGetValue(type, out var list))
return;
foreach (var action in list)
{
var cast = (Action<T>)action;
cast(arg);
}
}
pretty decent tbh
you're tap-dancing around the type system here with that MASSIVE downcast
but, whatever
you ensure that each list only contains things of the appropriate type
my memoizer does roughly the same thing
add some unsafe โจ
using a pointer as a joke
This still can't abstract away the difference between a zero-argument function and a one-argument function
But you could take it a step further
You could accept a Delegate and then use reflection to pull out the parameter types
and then..idk, put them into a System.Tuple and make your map a Dictionary<object, List<Delegate>>?
You'd still need one method for each number of arguments when invoking a method, unless you want to do lots of reflection
I'd just duplicate some code so that I don't want to throw up every time I look at it ๐
it'd be very tidy from the outside
oh god, i just thought about using currying
my silly cast with an allocation is so much simpler, I think I'll just stick with it lmao
I would do this
just add an extra list for zero-argument actions and add separate AddListener and ExecuteListener methods to go along with it
Hey all. A bit of a crazy question because I feel a little dumb not knowing the best way to do this. I'm trying to paint a graphic in a [7,14] Grid. I need to find the closest point to my mouse. What would be the best approach in order to find the closest point to my mouse without iterating through THE ENTIRE grid of points?
I was thinking of something similar to a binary search where I just splice the grid in two using two extreame points. Find the closest and drop the other half.
But would this be the best approach?
I think the best way is to use a 7x14 grid of small buttons and map each area of a button onto a texture
lmao ofc!
or use the IPointerClick event
But if this grid has uniform sized cells and you know its position + size then you can easily figure out the cell a position falls in.
However this graphic must also be painted if the mouse is outside the grid
Closest to
you can still "clamp the pos inside the grid"
use Plane.Raycast to pick a point on a 2D plane, followed by Grid.WorldToCell
Plane is constructed from a point and a normal vector
I did not know about the Grid.WorldToCell method. Thanks!
it's slightly tricky to spot in the docs
it actually comes from GridLayout, the abstract base class of Grid
Oh lol. None the less thank you!
for Plane, the position will just be the position of the object the Grid is on
and the normal should be its forward vector
var plane = new Plane(grid.transform.position, grid.transform.forward);
Is forward just an identity vector? 1,1 on the grid space?
you can use this to shoot a ray from the camera onto a plane
you need to figure out where in the world that ray intersects your grid
so, no -- this is the direction the blue arrow points in when you selected the grid's game object
Oh Its normal vector.
Or its like point away kinda vector. God my linear algebra is so rusty
A normal vector points out of a surface
Also since this game is 2D I kinda just used Input.mousePosition and used cam.ScreenToWorldPoint to get mouse position.
if its all 2d you dont need a plane then, just figure out the world pos inside the grid
yep. So grid.WorldToCell is all I needed
Just clamp the X and Y within the size of the grid and bam. I got what I needed.
Do you not see the space at the end 
I am making my own renderer for sprites in 3d environment, and I want it to have Screen Space Occlusion like Lens Flare (SRP) have, how can I do it if I can?
How does SSO even work for something like a single quad? Also not the channel for this type of question. Try asking in #archived-shaders if you're interested in making your own spriterender shader.
Quick question - what's wrong with my bit comparison?
TargetLayers.value & (1 << other.gameObject.layer)
it's giving me the "cannot implicitly convert int to bool" treatment
TargetLayers is a layer mask
What you've posted is fine, the issue is where you're assigning this. This expression creates an integer, but you are trying to use it like a boolean.
actually yeah ๐
thanks
it was put raw in an if statement
guess I kinda expected it to auto-interpret 0 as false and 1 as true
That's the case in C/C++ and other languages, but not the case in C#.
oh, I thought is is done via something like a class or function in mono behaviour, sorry
Here is my hierarchy. How can I change the panel? Currently they are spaced so the first is x -960, the 2nd -480, 3rd 0, 4th 480 and the last 960. The width is 480. So I wanted to change the x position to change the panel, but I'd like to keep my Horizontal Scrollbar and other elements afterwards. My goal is to make a ClashRoyale-style menu. So when you slide left, it changes the menu.
It's difficult to understand what you mean here, a screenshot of the actual UI would help.
Also #๐ฒโui-ux
So I'd like to be able to rotate between these menus, but I don't know how to change the menu displayed - 3 is the default. And for the channel, it's the script I don't know how to do, just the x position change. Should I go to #๐ฒโui-ux anyway?
You would just need to modify the x component of the anchoredPosition or position on the RectTransform
Like that ?
public RectTransform contentPanel;
contentPanel.anchoredPosition = new Vector2(-480, 0);
If yes, it doesn't matter, the code is executed correctly.
What do you mean by "executed correctly", so is it working?
You essentially need to modify the x value in the direction of desired translation (this isn't a rotation btw)
so if the width of the cards are 480 something like this:
contentPanel.anchoredPosition -= new Vector2(480, 0);
the other direction would be +=
Yes, I tried, but it doesn't change anything.
Show your entire code
public class SnapToPage : MonoBehaviour, IBeginDragHandler, IEndDragHandler
{
private const int MinScrollDist = 1000;
public RectTransform contentPanel;
private Vector2 _startDragPos;
private readonly List<float> _pagePositions = new List<float> {
-960,
-480,
0,
480,
960
};
private int _currentPage = 2;
private bool _isDragging;
public void OnBeginDrag(PointerEventData eventData)
{
_startDragPos = eventData.pressPosition;
}
public void OnEndDrag(PointerEventData eventData)
{
Vector2 endDragPos = eventData.position;
float scrollDistance = endDragPos.x - _startDragPos.x;
if (scrollDistance != 0 && Mathf.Abs(scrollDistance) >= MinScrollDist) {
int direction = scrollDistance > 0 ? -1 : 1;
int oldPage = _currentPage;
int newPage = oldPage + direction;
_currentPage = newPage;
float newX = _pagePositions[oldPage] + direction * Screen.width;
contentPanel.anchoredPosition = new Vector2(newX, 0);
}
}
}
What is this component on? the cards or the content panel?
Also are you using a scrollview?
On a scrollview
The ScrollView should just handle the dragging for you, so you shouldn't need any of that code
Yes, because if the player scrolls 240, he'll get half of 2 different menus.
And it'll never be well centered
Okay I see
All you really need to do is in OnEndDrag is figure out which card is closest to the center and snap to that. I don't believe you need to track mouse position or drag delta at all
@cedar verge Also I don't think your approach is going to work because the ScrollView has full control of the content panel's position, you essentially need to create your own ScrollView component that does what you want
You could instead also try and set the scrollbar's position to where it needs to be so that the card is centered, but you'll need to calculate the normalized scroll position for that
I have this code which loads addressables. And it works fine until the address is wrong. I want to handle those errors and still continue running the game even if the address is wrong. I tried encapsulating it in the try/catch block but that doesnt work
Error reports happening on the first line, LoadAssetAsync
I don't think this is the most comfortable for the user. On Clash Royale for example, my inspiration, a very quick 0.5s slide of 100 is enough to turn the page. Menu switching is very intuitive on this game.
That is strange, the only thing I can think of is that they are manually logging the exception just like you are trying to do
Does maybe the Addressables.LoadAssetAsync<T>() already have a try/catch?
Meaning what you want is probably the default behavior
its unity code but going 2 levels deep, doesnt seem like it
Thats the check for success part, i had log in it and it is reached
my problem is that unity pauses game if it happens
Do you have error pause on in your console?
just turn that off
it won't happen in a build either
lol it has to happen at least once to realize
I dont even need try/catch, everything worked even before
I think I may have misunderstood something... I'm trying to make a grid system but with 3d gameobjects. Since I'm making a tactics game I need like a GridState but I'm not getting anything useful info from the tilemap
My palette is just a simple cube
tilemapLayers.AddRange(GetComponentsInChildren<Tilemap>());
foreach (var tilemap in tilemapLayers)
{
ScanTilemapLayer(tilemap);
}
}
private void ScanTilemapLayer(Tilemap tilemap)
{
foreach (Vector3Int pos in tilemap.cellBounds.allPositionsWithin)
{
//Nothing in the tilemap.cellBounds.allPositionsWithin
Use Awaitable or UniTask instead of Task!
why?
Both are better suited for unity than Task and should produce less garbage. Both offer replacements for common coroutine stuff too.
Awaitable is 2023+ however
Do I need like tilemap collider or it will never work?
You aren't doing anything Physics related so I don't see the reason why you'd need a collider or whatnot.
I'm doing something like this but code aboves doesn't find any tile
With the data you've shown, you ought to simply check if the loops have got any data at all first by logging the number of tile maps in the layer or contents of the all position within.
If I have a Terrain and a decal, how can i do so the decal projects into it? I want only the terrain to be able but the problem is decal uses layers from mesh renderer and my terrain does not have it
If it's not exposed in thet inspector, try changing Terrain.renderingLayerMask
where do i do that?
It takes a uint which you probably want to copy from a Renderer's rendering layer mask field
Ah so it is in the inspector
yeah, i didnt even try to check terrain settings, just assumed it was only a mesh renderer option
hi, here i want to rotate a object on all its axis, which depends on the input...but when it is rotated 90 on x and then i want to rotate it along the green axis, the inspector value turn _90, -90, -90) something like this...i can't put these values as i don't know these...i just have some arbitrary values based on the inputs...how do i use them to rotate it correctly? as an example you may take, i want to rotate it along the green line while it is rotated 90 on x
maybe i messed up the explanation
With code or in the editor?
with code
It's still a bit unclear which space you want to rotate in
World vs local
Relative to its own Y axis or world Y axis, etc
This is a result of two things:
- Gimbal Lock
- Euler angles being a terrible way to track rotation.
Anyway as for the specifics of the answer to your question, you would have to get very specific about the nature of the rotation you want to do if you want a good answer here.
i want it to rotate like this
based on my input
use transform.Rotate
it will rotate in local space of the object by default
but that continuously rotates, right? but i have some inputs...let me clear it out a bit...
hey guys im making a vr game and im using a animation input script that i borrowed and im trying to do a use reference but its not there
it doesn't continuously do anything. It rotates when you call it, by the number of degrees you tell it to rotate.
If you call it each fraem, it will rotate each frame by the amount you tell it.
wdym by "it's not there"?
also I don't see any references here
InputActionProperty is a struct.
Is this your "zero rotation"? Like the default rotation you want it to be in
look at your console window
see if you have any compile errors and fix them
i dont
also what isn't it right there?
i have a glider,,,this is rotated 90 on x, as you saw in the vid...now when player presses right or left, the object will rotate on its local yaw and local roll axis
theres suppost to be a checkbox that sayss use reference
transform.Rotate(0, yaw, roll)
press the ...
it's probably in there
or press the + and then it might be in there
actually its glider...it will stand straight when it is on ground, again will lie like this when flying
got it thank you
something like this is happening
when i press forward a bit...it starts to rotate forever
Are you using a controller
i just want it to rotate, when i press, and stop when i don't
right now a keyboard
When you press nothing , should it return to zero rotation or stay where it is
as you see in the code, i am adding up the value while i am pressing to accurately rotate it based on the input
Does that answer my question though?
yeah yeah
Rotate adds to the rotation so maybe that's not what you want here
It doesn't just set the rotation to the given values
hmm, it seems like it,,,i can't find a way out
transform.rotation = Quaternion.Euler(_, _, _)
Or set the base rotation first and then apply additive rotations with Rotate
Latter is probably better
so tie it to your input.
like i said, it should set the rotation value, but Rotate doesn't set it, just adds it on top, i guess
you are tying it to these variables for some reason
and adding to the variables
so the variables end up causing continuous rotation
you want to either:
- add to your variables then SET the rotation based on them
or - use transform.Rotate directly with your input
e.g.
transform.Rotate(x * Time.deltaTime, 0, z * Time.deltaTime);```
(you only have two inputs so it's not clear how you plan to control 3 axes of rotation with only 2 inputs)
when pressing left, right, the object will rotate horizontally and also will rotate a bit on roll axis
Is this you telling me what's happening with your current code or what you want to happen?
i wanna do the first one, i am adding my input value to a vector, and then want to set the rotation which will show the object in the gameplay according to the vector3
Ok but your problem then is you will run into gimbal lock
this is a classic case of gimbal lock
it happens, i want it to
relying on euler angles to do this is not going to work out
if(Input.GetKey(jumpKey) && readyToJump && grounded)```
it's because you're using GetKey which is true for all the frames during which you hold it
so depending on how long you hold the key and how long you are grounded, you will get different behavior
you should use GetKeyDown to detect only when you first press it
it is kind of, i want to use the transform.Rotate and also want to set the value...hybrid
Why are you so married to the idea of using euler angles
You shouldn't use code that you don't understand
Won't learn anything that way
And it's almost impossible to help (without spoonfeeding) then
Ah yess delete the messages and make me look like a skitzo
i will give a brief what i am trying to achieve....
the object is rotated 90 on x axis
press up, down key --> accumulate the input and then set the value to x axis
press left, right --> accumulate two values, one for setting to its local yaw axis, another for setting on its local roll axis,...can you help me with this now...
would this become easier if you make two objects
a parent object and a child
I'm still having trouble following exactly what the desired gameplay/control feel is here.
no, think like it is a glider...(actually it is a glider)
you want to turn right --> glider will rotate on its yaw and also on its roll a bit
you press up --> glider rotate downwards like a plane going down
with a glider or plane I would expect right/left to control roll and up/down to control pitch
yaw would be a third control if you have it at all
but it kinda sounds like you want the yaw control to work based on the world space y axis
but the pitch and roll to work in local space
probably layer order issue? hard to tell also not a code question
#๐ปโunity-talk probably better. You'd have to show the setup to be sure.
alright
yeah yeah
something like this
i can't get over it, any suggestion?
for me at least, if i press up while contrlling a glider, my glider should turn up, and i start to lose more speed
if i turn down, my glider should turn down, and pick up speed
if i turn left and right, my character should lean, and i should start turning slowly in that direction
if you want it to work this way i would change the rigidbodys gravity constant to "imitate" having a glider, thenn making your forward velocity constant, and slows if your x rotation is above 0, and speeds up if you go below 0, and if you turn, slowlly turn the character/camera in the direction over time
normally, when controlling something like a glider in a game, you dont accumilate input alll together, you just apply it as you get it, then use what the character currently is doing after the input to move your object
It's because those things don't exist
Unless you have something named PlayerCam that error is bound to happen
how you tryed to fix it
what is "something"
is it a class?
this isn't names of cameras
That error disagrees
its classes
You might need to do beginner scripting in https://learn.unity.com/pathway/unity-essentials
learn what components are n other coding c# essentials
is it possible to nullify an abstract class (non mono)?
I'm having this weird bug where it's not finding null slots, but then it is?
On a weird note- anyone ever have an issue where you save and compile, but the code doesn't work? But when you add a debug log and recompile and run the game, suddenly it registers?
I'm also having this "if you click on a class in the inspector, the logic breaks" but when you click off (cannot see it in the inspector) it stops breaking?
These are two strange issues that seemingly affect my question partially
what do you mean by "nullify"?
like set equal to null
classes are reference types, so yes
it makes sense when its a mono since you have to actually provide an object. but as a pure class created through new() it seems like it has issues
monobehaviours aren't really special in that sense
weird. for example this wasn't working but then suddenly started working as soon as i began debugging it.
// โ
**Explicitly create empty slot instances**
var emptySlot = new ItemSlotInfo(null, 0)
{
gridIndex = i,
itemIndex = i
};
Debug.Log($"Creating empty slot: {key}");
emptySlot.item = null;
if (emptySlot.item == null)
Debug.LogError($"NULLIFIED SLOT");
else
Debug.LogError($"WAS NOT NULL!!!!");
items.TryAdd(key, emptySlot);
with the new i explicitly assign null
public ItemSlotInfo(ConcreteItem newItem, int newStacks)
{
item = newItem;
stacks = newStacks;
}
then again you see i assigned it under the debug log, and it worked. it seems like it needs to be set twice to register
that's not really a thing that happens
code generally does what you tell it to do
not necessarily what you mean
with my code, shouldn't it apply null within the new statement? i.e. the emptySlot.item = null; is redundant?
it should, yes
ya now it's working, its so odd. I must be missing something or there's a compilation issue
i mean if "empty slot" is a common situation, you could even omit it from the constructor, it'll be defaulted to null (though i'm guessing that's not a common enough situation to justify it)
what's ConcreteItem?
I definitely know there's a consistent issue with this one class i have, where if selected in editor (mono) it will bug out
Concrete is the unabstracted version of Item
ok, but what is it
a class that just inherits item
public abstract class Item
public class ConcreteItem : Item
does it inherit any equality overloads?
Concrete is empty, it just inherits and unabstracts thats it
[Serializable]
public class ConcreteItem : Item
{
}
what's the point of Item being abstract then lol
polymorphism apparently
well no, that's unrelated
if Item doesn't have any abstract members, why is it marked abstract?
your issue is that Unity's serializer doesn't support null
it will always create an empty/default object
It therefore also doesn't work well with interfaces and abstract classes
probably because i was treating it like a template, then having intermediate classes tack on functionality. wanted to keep some kind of root blueprint type class that was not accessible
you can do that with a non-abstract Item as well
O gotcha, i'm stuck on the issue of using "stacks == 0" as a check vs "slot.item == null" as the check
[SerializeReference]is your friend if you need to serialize a null value and/or abstract classes and interfaces
how does that work if a class/struct doesn't have a zero-param constructor?
what do you think is better to dictate whether an inventory slot is empty- it being "null" or the stacks being zero?
b/c it seems like this null thing is an issue, whereas 'stacks > 0' has to be true for something to "exist" though i'm trying to futureproof/predict any potential bugs
still just creates a default valued object
you could have a designated EmptyItem, like old minecraft
not saying that's better but that is another alternative
Also, is the abstract Item a bad thing to have, like adding a redundant step? And I should get rid of it, and only have "ConcreteItem" (rename to Item) and make that un-abstracted?
oh unity uses reflection to make the object, doesn't it
yeah, there's not really a point in separating that in 2 steps
something like that
it's not bad; it's just unnecessary
oic, so polymorph from concrete and get rid of the inherited one? Just making sure this doesn't become a potential lock out issue, where i can't undo this lol
one class, "Item" (non abstract) as the root for all things*
yeah that's fine
ok. I believe that makes sense, i can always just append from that level forward
when you say 'empty item' what would the context be?
would that be some kind of id tag? like "groupID" and then i assign "emptySlot" then first or default/contains to find the first field ofthat type inside the inventory?
I could add a string field like that here in the slot:
[System.Serializable]
public class ItemSlotInfo
{
public int itemIndex; // The index in the backend data
public int gridIndex; // The index in the visual grid
public ConcreteItem item; // The item in the slot
public int stacks;
[Header("Shop Data")]
public ulong itemCost; // the cost in iron
public string itemID => item?.itemDefinition.itemID ?? string.Empty; // Convenience for accessing itemID
public ItemSlotInfo(ConcreteItem newItem, int newStacks)
{
item = newItem;
stacks = newStacks;
}
no clue what you mean or what you're asking tbh
previously i was adding/removing dynamically. but now im prefilling a ton of empty slots. this was a new trade off because of the ui/data desync and some edge case issues
do you know how minecraft used to do it? (im not sure if minecraft currently still does it)
you will have a script that allows you to move with an azerty keyboard ??
what im saying is 'how can i detect if a slot is empty, since null detection seems to be an issue' due to unitys caveats
i do not
so before, your inventory was variable size?
it still can resize. but previously it was toatlly empty list. as you get items/drop them it resizes
but conflict with UI slots vs resizing dict. plus its not performant doing that many operations
what's your inventory model here? im confused
better to "store empty slots" apparently and pay that cost
if it's not a fixed size with a fixed ui, it wouldn't make sense to show empty slots from a UI perspective, no?
generate a bunch of slots. the problem is adding items. i dont know how to detect if a slot is "empty". it finds an "empty slot" aka a pre-existing one, then writes data to it
so the ui now matches the data. if there are 6 inventory slots, there are 6 ui slots as well
so they are directly correllated
but since i cannot really be like firstDefault(x => x.slot.item == null) or something like that, need another way to indentify a "slot is empty" within that dictionary
step away from your implementation for a sec. what are you going for? what's your inventory model?
ok, its an inventory system where you can store items. The inventory size can scale as you add/remove bags. like 10 -> 12 or 12 -> 5, depending on what is equipped.
This will automatically call the items.dictionary to generate new "empty slots" so that there is "space" to add items to. You cannot add items to a non-existent slot. So 12 inventorySize means 12 slots that items can potentially go into.
You can also change the positions of items in the UI via "gridIndex". itemIndex referred to the link between UI and data, as previously you could have more UI slots then actual items (6 slots in ui, but have 0 items in backpack, aka your bag is empty, but you can hold up to 6 items). I'm in the process of moving away from that.
Right now, I am trying to figure out how to say "these slots are empty. there is no item data in them". but need a way to "tag" it as such. Right now i don't have a field that does that. I was attempting to do if(slot.item == null) but that clearly has issues, so I need another solution.
what I thought you had suggested was some kind of string tag. like all inventory slots will be automatically assigned "emptySlot" so that a forloop can easily loop over it and find those and just pick the first one then overwrite slot.item = newItem and slot.stacks = newStacks.
I believe its just a standard inventory? Kind of like VRising or minecraft? You collect items and can move them around visually in the inventory and they retain their position?
Only difference is if you alter the inventory size, it needs to recalculate that.
But the main issue right now is just "how do i assign that something is empty, because null doesnt work apparently"
ok so you don't actually have a list of slots, you have a list of item stacks that you map into slots, why not actually have a list of slots that items can be transferred between?
about the EmptyItem thing, it's just an extension of your Item with no data
or perhaps you could assign a magic number for item id
public SerializableDictionary<string, ItemSlotInfo> items = new();
like id = 0 means it's empty
o gotcha, that makes sense, but seems like a permutation of just checking the stack count. unless that's slightly less expensive
you should not care about what is expensive or performant at this scale
you would need to have millions or billions of slots for it to matter
gotcha that's true
your focus should be on what makes sense and is easy to understand and work with; don't fall into the trap of premature optimization
the items dict above is the key GUID (not really used, but apparently helpful for quick lookups in the future) and the ItemSlot itself which contains subfields like item and stacks
the value is what is targeted
for sure, just trying to balance things out
and also i dont want to manage a ton of fields at once. thats more the concern
less is more
a 0/1 binary flag would work though for sure. either its empty or its not. that def makes sense
that's called a boolean
true that is even cheaper lol
you could make it a property that just checks that stack count
it isn't
it just makes more sense to work with
interesting. but ya sounds like alot of ways to approach the issue
easier to come back to in the future for sure
the reason i mentioned performance was because i was already starting to see some issues. but in regards to instantiation. which is why i swapped over to 'pre-generated slots' rather than add/remove constantly
started to see a few seconds of delay when switching tabs which is a big problem
none of what's been mentioned would be the bottleneck in something like that
i'll stick with your suggestion though its straight forwards
like i said before; don't fall into the trap of premature optimization
if you're seeing performance issues, do profiling to see what the issue actually is
sounds like adding that property/field and then converting concrete to item and removing abstraction should fix alot of issues
i think its because its instantiating alot of things. i still have to learn how to pool some stuff like that. so its more of a 'pregenerate, then toggle on/off'. that should fix the issue in theory
12 slots is not a lot
alot of interesting trade offs. memory vs framerate
o no, its like 60 that this had an issue
instantly generating and filling all the data
60 is also not really a lot
hmm. its probably beacuse i destroy them all, then regenreate
each time a shop tab is clicked, it does that
oh yeah that's.. not great
ya im sure thats why. its doing too many operations in a milisecond
pooling/something like it should solve that
it's probably in the gameobjects part though, not in the constructing part
yea
filling the data should be cheap
as i understand it
instantiating seems expensive
cool, i'll give those suggestions a shot, thanks
very much so
Hey everyone,
I'm trying to get my first-person character controller to move smoothly on a moving and rotating platform (like a ship) without making the player a child of the platform.
Right now, Iโm using a raycast to detect if the player is standing on the platform (by checking a specific layer), and then I apply the platformโs movement and rotation delta to the player in LateUpdate().
What Iโm Doing
-
Raycast Down from the player's feet to see if they are on a platform (using a tag or layer).
-
If theyโre on a platform:
Store the platformโs position and rotation from the last frame.
In LateUpdate(), calculate how much the platform has moved and rotated.
Move the player by the same position delta and rotate their Y axis to match the platform.
- If the player jumps or steps off, the raycast no longer detects the platform, so they stop moving with it.
The Problem
It kinda works, but the player slides when the platform moves, especially when it turns only. Since Iโm using a CharacterController, Iโm applying movement using Move() instead of setting transform.position, but it still doesnโt feel right.
The sliding only happens when the platform turns, but its really slow. But after a while it builds up and than the character falls off
What's the best way to trigger a function on another script? For example, i want to have a damage function that is triggered when it touches a damaging object, but the damaging object decieds how much damage to do, rather than having a different case for each object
Get a reference to it and call the function
Thanks! I figured it out using on collision enter.
Do you think Unity will ever get built in support for serialized interface references?
by "built in support" do you actually mean "draw a property drawer for it"? because you already can serialize interface references with SerializeReference
And that works for unity objects that implement an interface?
I've used SerializeReference before but not for unity objects
hey maybe consider providing all of the relevant information when asking for something instead of leaving out crucial information like that
thought that would be implied, but you're right
Why would my movement be causing my camera to move slowly? (yes I know this code is probably a mess and could be better)
https://pastebin.com/DZAY9jCp
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
how is your camera supposed to move?
Quickly?
Not at all?
Is there a script that moves the camera?
We need more details
There is another method in the same script, and the camera gets slowed down significantly when ever the player starts to move. I can send that method as well, but I know it's this method that's the culprit
You should share all of the relevant code.
Share the full script
It's not even clear where HandleMovement is being called
it's a really long script
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
(that' really not that long)
It is for me, usually mine are at most like 300 lines lol
yes it is
Ok so what do you mean by the camera moving slowly then?
Isn't it attached to the player?
rotation
sorry miscommunication lol
ok one big problem is this:
float mouseX = Input.GetAxis("Mouse X") * MouseSensitivityX * Time.deltaTime * 100f;
float mouseY = Input.GetAxis("Mouse Y") * MouseSensitivityY * Time.deltaTime * 100f;```
you should not be multiplying Time.deltaTime into your mouse input
mouse input is already framerate independent
this is going to introduce problems such as the look speed changing when your framerate changes
i added that to try and fix the issue so that's not causing it I just forgot to remove it
That's also the only code that seems to deal with rotation
yeah it's something in the movement code
and you only seem to do up and down rotation on the camera directly
the rest of the rotation is rotating the player itself
Is it vertical or horizontal rotation that is slow?
The ApplyViewBobbing method is the method moving the camera
That is indeed moving the camera but not rotating it
both, but it only happens with the controller
right, but they asked about moving, unless they really meant rotating
i meant rotating
ok... more information that would have been helpful at the start.
Yeah read the convo
i just learned this while testing lol
ok so ironically gamepad input DOES need Time.deltaTime
mouse should not have it
but gamepad in Update needs it
that's your issue probably
I guess I'm blind, my bad
Why.. are you using new input system but reading all axis and mouse stuff separately
yeah that's a whole separate issue
I'm just switching over to it
like just now
this just slowed down the camera rotating left and down even more
this is what i did
float gamepadX = (lookRight != null ? lookRight.ReadValue<float>() : 0f)
- (lookLeft != null ? lookLeft.ReadValue<float>() : 0f) * Time.deltaTime;
float gamepadY = (lookUp != null ? lookUp.ReadValue<float>() : 0f)
- (lookDown != null ? lookDown.ReadValue<float>() : 0f) * Time.deltaTime;
yes it will slow it down. You need to multiply by a sensitivity value as well
it won't be framerate dependent anymore though
which should fix your problem
Just curious, how is mouse input frame rate independent?
Mouse input comes in as "the amount the mouse moved this frame":
moving still slows it down, and its slower in the negative directions and faster in the positive directions
Ahh duh lol
the faster in positive direction is probably due to your weird little math with the two separate input axes instead of just making a single 2D input vector or two 1d axes
how do I switch over?
make a single action for "Look"
set it to
Action Type: Value
Control Type: Vector2
bind it to the joystick you want
And in your code you just do:
Vector2 lookInput = lookAction.ReadValue<Vector2>();```
qui parle francais??
Anglais seulement
ok
This completely fixed all the issues
should I be doing the same thing for movement?
Hey does anyone know a good tutorial for GPU instancing
the bug just randomly came back and I didn't even change anything
and now its gone? i am so confused
Are you doing anything specific or just writing shader support GPU instancing
i have a lot of trees and grass in a terrain and i feel like i should optimize it
i tried following a tutorial because ngl i dont know how to code but i can't figure out why theres an error in one of the lines
#โฐ๏ธโterrain-3d or #archived-shaders possibly more appropriate
it's back ๐ญ i'm messing with how sprinting is triggered in my code, and that seems to make the bug come back and I have 0 idea as to why
ohk thanks
seeding Random.InitState from one scene affects randomization uniformly in all scenes even if they aren't loaded at the time of init?
Unity's Random state is completely static
it doesn't know or care about scenes
what does a scene have to do with Random? its a static method and doesnt care what scene u are in
if i had a dime for every api, framework or engine that these very rudimentary things that should be predictable, weren't...
The docs will sometimes mention if theres anything weird, but the unity stuff is mostly fine
What are you using Random.InitState for tho?
I'd recommend just using System.Random instance
You might never know what consumes static random
is there some low level code calling on it in unity itself? that seems like exactly the kind of quirks i was talking about
but more or less it would just only matter for the navigation map gen
i'd init the state right before that
I don't think it would, but if you have choice to avoid footgun why not
i presume UnityEngine.Random is for user code only and not engine
but i do also think its better to use a specific System.Random instance
yeah that would be a sure thing anyway
or find some other random num generator thats consistent with seeding like mersenne twister
That too if you need to ensure consistency across versions
Hey all, not sure where this question is appropriate but I am just wondering if anyone knows why the "FBX Exporter" package would be exporting no models, I am specifically trying to export a terrain but I've tried all sorts of meshes to no avail. It always exports as a very small file which I would assume couldn't realistically have a mesh ~12kb or so. Any help or advice would be appreciated!
I believe so, I've seen guides showing it be used as such. But I have also tried exporting other meshes to no avail.
what about gltf export ๐ค
it is vague about support but may be worth a try: https://docs.unity3d.com/Packages/com.unity.cloud.gltfast@6.10/manual/index.html
Hey @heady iris and @hexed pecan, sorry for the ping, you were trying to help me a while back with a rather weird issue, having custom defaults for json values that get overriden if something's defined in the config, you can see more details in the message I am replying to.
I managed to solve it by using [OnDeserializing] attribute(thanks DeepSeek).
E.g. would be my color class:
[OnDeserializing]
private void Reset(StreamingContext context)
{ R = 0; G = 0; B = 0; A = 1; I = 1; }
Now I can simply assign the default color value in the ResetToDefault method:
public void ResetToDefault()
{
ColorOverLife = DefaultColorOverLife;
}
And it will use correct values in all scenarios:
Fully defined color(RGBAI) -> Use those
Partially defined color(e.g. BA) -> Use value defaults from the data type(in this case Color)
Not defined in config -> Use the DefaultColorOverLife defined in the editor
Before this, I had to have a fairly annoying workflow:
public void ResetToDefault()
{
ColorOverLife = null;
}
public void Load()
{
ColorOverLife ??= DefaultColorOverLife;
}
Where ResetToDefault got called right before loading the config and Load got called right after loading the config.
As I said before, for a solo dev this isn't a big deal, however, considering the fact this is meant to be used as more of a framework, it is quite annoying.
Pictures
- Fully defined(Uses everything from config)
- Partially defined(Uses config values+default color values)
- Not defined(Uses the in editor defined default values)
Thanks for some useful attempts and suggestions either way, hope this helps you in the future!
I appreciate the suggestion and will definitely check it out, at-least temporarily I found a user-made script which compiles terrain to .obj which works for what I am currently doing. Thank you though!
Forgot to reply to the question ๐คฆโโ๏ธ
I'm using the UI Toolkit to build my menus, how can I use an event system with it?
#๐งฐโui-toolkit has its own internal event system and doesn't use the UGUI one.
How does it work?
it JustWorksโข๏ธ what are you actually trying to accomplish
Have you checked the documentation?
Have a controller switch and click different buttons
there's like nothing on there
Note the UI Toolkit docs have more or less been folded into the main Unity docs
Since it's a core package
I'm confused on what I'm looking for in the docs. Is this what I'm looking for? It doesn't really tell me how to use the Standalone Input Manager:
https://docs.unity3d.com/6000.0/Documentation/Manual/UIE-Runtime-Event-System.html
the Standalone Input Manager is used with the ugui Event System.
This is from the link you just sent, you should maybe try reading the information:
The Input System package offers enhanced configurability compared to Input Manager. You can use the project-wide actions asset to set up how NavigationMoveEvents, PointerMoveEvent (โUI / Pointโ action), PointerDownEvent, PointerUpEvent (โUI / Clickโ), WheelEvent (โUI / ScrollWheelโ), NavigationSubmitEvent, and NavigationCancelEvent are generated for UI Toolkit.
there's also a handy table directly below that which tells you what you need
The Standalone Input Module dispatches events to UI Toolkit elements. This is why I thought I needed it.
did you read the table directly above that
that is for if you are using both ugui and uitk with the input manager (not input system btw)
UI Toolkit elements with Input System package so I need to use the Input System Package (New) or Both for event handling
which is just the The Standalone Input Module
please read it again
Yes I know it says no scene components required but I want to use the active input handling
which it says to use the input module
wdym "i want to use the active input handling"? that's just a setting in the project settings that determines whether you are using the input system, input manager, or both.
if you are using just uitk and not ugui then as the table says, there is No Scene component required
I didn't know that was a setting so I was confused
then read the information on the page
there is an entire section titled Set the active input handling system
Okay, but nothing is being selected when I hit play and my controller does nothing. Also my input settings looks completely different than on the website:
what version of unity are you using and what version of the input system package do you have
2022.3.20, and 1.7.0 which is the latest
yeah mention that next time. you need an event system
https://docs.unity3d.com/2022.3/Documentation/Manual/UIE-Runtime-Event-System.html
and for future reference, when looking at the docs make sure to change to the version you are using so when you link documentation you are reading you are linking the correct version so nobody assumes you are using a different version
Still nothing gets selected at all when I add those
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
{
// code code code
}
Hey guys, how to fix this light problem?
If there's an actual coding problem, post away, otherwise #archived-lighting. Also be more descriptive to the problem
OK so I have a question for y'all:
I have some wall sprites in a 2d game. I need to change the size for each of the wall blocks I place in.
The more performant but tedious way to do that would be to manually modify each of the box colliders to match the sprite (can't do polygon collider cause I modify the sprite renderer values, not transform)
Instead, I just wanna make a script that will modify its box collider 2d value on x and y based on the sprite renderer values
This is technically less performants cause I got all these blocks with a script on each of them but am I worrying too much about this? It's a webgl game so I'm careful but what do you guys think about this?
for simple stuff like this, don't worry about performance until it becomes an issue; once it does, do profiling to figure out where the issue actually is, rather than doing random optimizations
I mean, it's not a "random" optimization but sure, I would like that to performs well for lazyness reasons so I will try it
but you can't be sure if it's actually the bottleneck that's causing performance issues unless you actually profile it
what you're suggesting is still most likely performant enough
computers are fast
yeah it's supposed to work on mobile browsers as well
webgl
still pretty fast
Good afternoon everyone, I'm making my RTS now, and I have a problem, I want to make squads like in Wargame/broken arrow, but I don't understand how to implement it in the code
Can you explain how squads should work a little more?
I'd start looking into tutorials how to select your units. I've seen quite a few of those on youtube
then spend the next year or two perfecting your swarm AI pathfinding
You have a squad, it has 6-12 soldiers, they have common health, but different weapons, one has a rifle, the second has a machine gun, etc., and they are one unit, moving, attacking and all that as one unit
maybe you have seen such units in world in coflict, wargame red dragon or brocken arrow.
Like for example here, one squad, it has 6 soldiers, and in the game they act as one unit, they have the same health, but different weapons that can be changed.
Hey, something weird is happening with my tilemaps
here, my player can't move to the right
i need to jump and then try again
Can anyone explain this weirdness?
This is the "Clicking on a script inside the hierarchy causes logic to break (permanently sometimes)"
When you don't click on the script it works. But as soon as its seen in the inspector, all logic breaks permanently. The code looks totally normal and nothing stands out.
I think it may be a problem with unity's serialization or how it renders things?
Notice how when I don't select anything "UI/Inventory" related it's normal (empty slots).
But as soon as I click "Chest_Basic" which has UI And data linked, it breaks. This happens with any ItemSlot (my system) based classes. It makes no sense.
Sometimes it un-breaks when you deselect. When I run a build, since you cannot select anything, it's technically not an issue. But it makes debugging very difficult if I accidently have the class(es) selected and hit play, or want to see the fields for debugging (rather than blackbox where I can't see anything at all).
Any ideas on what causes this and how to fix it?
I've tried "hide in inspector" on all fields. But just selecting the class causes the breakage. And it's multiple classes related to a specific UI setup.
Any other UI classes have no issues. It's really bizarre.
If you click on an object and things break, it's likely due to code you have either in OnValidate or if you have custom ISerializationCallbackReceivers
or code in a custom editor
you also seem to have some kind of plugin adding buttons to Transform - any plugin might cause issues as well
hmm interesting, i'll check to see if I have any OnValidate code hidden somewhere
O ya, that's just custom resets. I'd be surpried if that causes it, since no other classes are breaking
Related to this question, I was wondering how sturdy is the OnPointerEnter/Exit methods in terms of firing?
probably not but - just listing possibilities
ya I'll try to narrow it down
they're totally reliable in my experience, as long as things are set up properly
I'm like paranoid that OnPointerExit won't fire and screw over some logic
THere actually are some weirdnesses
Especially around things like:
- locking and unlocking cursors
- moving the camera instead of the pointer
- focusing in and out of the game
You might want to check on these edge cases
Yeah, probably best to just raycast it manually
one weirdness to keep in mind, if you use Physics raycaster to have those events on colliders, keep in mind UI elements can cover colliders with rayhit from Event System
locking and unlocking cursors
moving the camera instead of the pointer
For these two in particular there are unfortunately behavioral differences between the old and new input system input modules :(((
Would an abstract inheriting another abstract cause UI breakages?
You really think im going to read that
Mistake im editing now
large code should not be posted in the chat but as links
look like a #archived-networking question anyway
Kk
Its not i dont think, the issue is something to do with the unity editor
What kind of UI breakages? Like in the inspector? Not in general.
ah ok, I'm slowly isolating the issue. It's definitely UI related
then you outta explain the issue before even posting code
I was i just accidentally sent it as i said
something to do with my "refreshUI" is breaking when the class is selected. hopefully soemthing mundane since I dont have any validation methods that im aware of. or any fancy calls
For some reason, this code runs the camera smoothly from within the unity editor, however when i build and run it it has a laggy, slight rubberbanding nature (will attach video in a min). Anyone know what may be causing this?
A tool for sharing your source code with the world!
do you have a Rigidbody on the object you are rotating with this code?
On one of them, yes. The player
ah I also see this is networking related
rotating an object with a Rigidbody directly via the Transform will break interpolation
Kinda, but to my knowledge it is not caused by the networking
Causing it to look how it does?
it can cause it to be jittery yes
Gotcha, thank you very much
most likely you can just replace:
cameraParent.transform.rotation = Quaternion.Euler(0, yRotation, 0);```
with:
```cs
theRigidbody.rotation = Quaternion.Euler(0, yRotation, 0);```
and that will preserve interpolation at least
Trying to do a full body IK but the camera keeps going to the legs and the fingers are getting messed up. Anyone know a fix?
where is the coding question exactly?
How do I make it so the camera stays at the head and not at the legs
parent it to the head bone?
this is a coding channel..You can try #๐โanimation
Ok I think i've figured out why. this goes back to my old question about the Item/ConcreteItem thing.
where "What is considered null in unity" when its not mono.
// Ensure the item is fully visible if present
if (slot.item != null)
{
// Set item visuals
panel.SetIcon(slot.item.GetIcon());
panel.stacksText.text = slot.stacks > 0 ? slot.stacks.ToString() : "";
panel.TogglePreview(true);
panel.FadeIn();
}
else
{
panel.TogglePreview(false);
}
This line
if (slot.item != null)
From my tests (and afaik), it seems like null is never really null when its a class and not mono. If mono, you have to supply in the reference. If not mono, null just "clears" the data (empty state) but isn't actually "non-existent"
Though I don't get why not selecting the class vs selecting the class initializes things differently. That's still odd to me.
Now the preview is "correct" but backend its still doing that null check when clicking on empty slots.
I changed it from != null
to
if (slot.stacks > 0)
and that solved part of the issue.
I think it just stems from that null check problem
something must be loading/refreshing when clicking on classes in the inspector, then thats getting passed along to my if statements that check for "null"
ah i think i know why
My class is serializable. supposedly unity doesn't destroy serialized classes (non mono). it just clears the field like I thought. If it was non-serialized (default) then it would actually destroy/null it
Anyone knows how to fix this? I'm using rider and I hate it's putting the serialized flag up there
wdym whats wrong with putting serializefield ?
oh you mean you want it inline ?
change your C# code style settings
Just the one with other flags before get this terrible lining
Something here probably
seems like it
the one I found only adds comma for multiples
Im still new to rider sry ๐
If you put attributes and the field on the same line we are not friends ๐
same, it has power but it's giving me headache for formatting and swiggles ahahah
I make an exception for SerializeField
even
Header
Serialized
property
is fine
its tbh the only attribute I keep same line
[SerializeField] private float t
[SerializeField] private float t ๐คฎ
but I dont mind
[Header("meow")]
public float stuff
its weird
Yep, removing "Serializable" from item fixed the issue. Now it doesn't break the UI or logic anymore.
But now its a complete blackbox. Cannot see the item details at all.
Any suggestions on how to kinda work with those limitations?
Either I change the logic to use "stacks > 0" and serialize the "item" class so debugging is easier, OR I leave item un-serialized and can use "slot.item == null" because unity can now destroy it. Trade off between easier debug but altering the core func, vs more difficult to debug (can't see data) but simpler system. How would ya'll approach it?
why dont you want serializable again ?
unity clears it to default but doesn't destroy it. so null checks will never work
its non mono
just a c# class
ahh right embedded pocos always get initialized
yer had gpt confirm my suspicion since i've consistently seen this
if you assign poco to null does it still do it?
it clears the data but doesnt removeit from inspector
its like the equiv of setting all fields to empty
it still exists
oh yeah ig the inspector is just constantly initilizing it
that must be why
that'd explain why it keeps breaking when i click on it....
sheesh lol hidden stuff. may just be best to blackbox it as a 'poco'
its lame but wont have to deal with issues like weird re-initializiation
there's no debugs/errors thrown so it's been a nightmare
i'll def have to keep this in mind going forward
I think you might be able to override the inspector for it and prevent that behavior
that makes sense, but most likely out of my scope of knowledge
yeah making another flag/bool would probably solve some issue but its dirty
i do like setting things to null though, that's much easier than 'acess this field, check if stacks > 0' or doing id tags
ya, i guess i can just stick with debugs. wish there was an easier way to stop that initializing lol
o well, good to know
yup, no easy way but custom inspector that overrides it would probably work
isn't that's what [NonSerialized] attr is for?
it will stop unity from touching it at all
o like it can be serialized but the inspector won't refresh it?
or are you saying the equiv of 'just don't serialize it to begin with'
no.. the editor wont touch it, that's it
o so I can have it exposed as a serializable, but block the inspector from refreshing/recreating it?
afaik thats for types that already serializable but so you dont want them showing in the inspector
like see the c# class in editor, but prevent unitys inspector from acting on it and breaking the system (refresh/recreation)
like [NonSerializable] public int someInt // wont show in inspector
o so its just a blackbox then? like hide in inspector?
pretty much
or do you mean wont show in inspector as in, you can see it, but the inspector cant
but if anything this one would've been better
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/HideInInspector.html
o ok, then its no different than not tagging it then
ya hide in inspector didn't work for serializables. that still caused breakages
but if there was a class i wanted to force hide then for sure
my issue is the inverse as ya know
'view in inspector, but block inspector from acting on it'
its purely for debug purposes
yes, maybe make a property
but if its just for viewing in the inspector I wouldnt even bother
You can make a custom inspector if you really wanted to , that can prevent auto initilizing it
cool thanks, i'll look into that down the line
glad this seems to be resolved for now. alotta interesting caveats
oh you want it to be serialized but not editable, or? im confused, sorry not following the conv above
You need to wrap your serialized classes in some nullable type if you want to prevent unity creating an instance such as a List or Array
The want to see it in the inspector but that comes with unintended consequences of unity always giving default values even when setting the data to null. They want to be able to null check which doesnt work on their class because unity inspector keeps initializing it
Or ideally SerializedReference if they actually had support
well you can always OnBeforeSerialize and OnAfterDeserialize to store that data in some serializable struct and reconstruct it in to object with custom logic after deserializing
^ that
so you will have controll how and when its recreated
but to use that you have to get good knowledge about SerializedObject and how it works with inspector so you dont get stuck
[Serializable]
public class NullableRef<T> : ISerializationCallbackReceiver where T : class
{
[SerializeField] private List<T> value;
public T Value => value.First();
public void OnAfterDeserialize() { }
public void OnBeforeSerialize()
{
if (value != null && value.Count > 1)
{
value.RemoveRange(1, value.Count - 1);
}
}
}```
I made that the other day
Fixes that bullcrap and cant be bothered waiting another decade for serialized references
https://i.imgur.com/A4NxWUe.png
Little funky but it's this or odin inspector
how can i add text spacing for each letter?
cause like B is bigger then I so i dont want I to have a universal 0.5 spacing for example..
float totalWidth = 0;
foreach (char c in Text)
{
totalWidth += GetLetterWidth(c) * Spacing;
}
float startX = -totalWidth / 2f;
float currentX = startX;
for (int i = 0; i < Text.Length; i++)
{
char c = Text[i];
GameObject letterPrefab = FindLetterPrefab(c);
if (letterPrefab != null)
{
GameObject newLetter = Instantiate(letterPrefab, transform);
newLetter.SetActive(true);
float letterWidth = GetLetterWidth(c) * Spacing;
float letterOffset = GetLetterOffset(c);
newLetter.transform.localPosition = new Vector3(currentX + letterOffset, 0, 0);
InstantiatedText.Add(newLetter);
currentX += letterWidth;
}
}
this is how i save them
uhh what are you building here and why are you making whole GameObjects for each letter?
TMP can do custom spacing: https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/RichTextCharacterSpacing.html
a text system, each letter has its own gravity, my own 3d text system
no im making my own system ๐ญ
Yes I see that, I'm wondering what the benefits are. Seems like a lot of work
interesting, but if you just want to use textmeshpro you can just space the vertices out
There are also kerning pairs you can set: https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/FontAssetsProperties.html#glyph-adjustment-table
probably other methods since the API is huge
it is a lot of work but i do require to make a whole text system
Ah, yeah that looks like the better idea
its not for myself, im making a level editor
but there is a different problem
nothing changed
the dictionary does nothing
is the code right?
i mean it looks... sorta ok at a cursory glance but there's some missing context too
i can give any context just tell me what u need, here is the other functions
well you only have very small offsets
an order of magnitude smaller than the letter widths
so it might not be noticeable
but offsets are what change the letter to different way, i need the spacing which is width??
or am i not understanding my own code ๐ญ
How can I calculate/predict the world position of a child after parent is rotated without actually rotating the parent?
Well can you explain better what part isn't working?
if i put spacing to 0.1 its equal to the same way it was before i added dictionary
wait a sec
i think my width are not right
Something like:
Quaternion rotationToApply = whatever;
Vector3 newLocalPosition = rotationToApply * childTransform.localPosition;
Vector3 newWorldPosition = parentTransform.TransformPoint(newLocalPosition);```
depends on the precise details of how you are calculating/applying rotation etc.
(this is assuming you are rotating by a certain amount not rotating to a certain new rotation)
Ah, so I realize why I separated Item and ConcreteItem into two things. Now its serialized vs unserialized. (before it was abstraction, which is removed now)
The problem with using just "Item" directly is that unity will drop all non-serialized data. And my "salvage bag" has pre-injected data from a tool in its list. It got totally dropped because I changed all logic over to "Item" only (to fix UI/data breakage)
But since Concrete inherits from item, I can simply just redirect editor side/pre-injected data to using the serialized version, and use Item for all runtime instantiated data. That should in theory stop any UI/inspector breakages while preserving item data in both cases.
I should be able to pre-inject data that will stick (ConcreteItem) and use runtime data separately (Item).
Pre-injection is a way to save resources, the list is premade so it just reads it. Whereas if it was runtime only like the rest of the system, I would need to generate like 90 things instantly. It went from 3-5 second delay to instant when using a preinjected list.
Does that sound about right? Or is there a better method? I feel like that's the simplest solution that's scalable. Separating runtime and pre-injected data into two types, and just having one inherit the other (ConcreteItem : Item) so that they are the same thing (one is just serialized)
Hi can I check how do I add more "Driven Axes" into the Cinemachine Input Axis Controller component?
Well, you're constructing everything at runtime regardless if you're pre-defining your items so unless you're skipping over some process it should be the same in terms of loading
either case, you'll probably want some lazy loading / async method to not run into these spikes
oh thanks
Hey guys. So me and my friend are doing a school project with unity. I tried setting up the collaboration thingy with plastic. But i keep getting this error. Oh yeah and i used a the first person game version 2021 (idk why that version but the newer version doesnt have the first person game)
help would be very kind
check package manager there is probably an update
2021 is kinda outdated tho
you should be on unity 6
or at least 2022
uhh could you tell me why?
wdym just told you why lol
oh sorry ๐ญ
Hi! where can I show off my unity project?
is it a really big problem? or is it okay
never a big problem, just depends what you need to do / features needed
at some point new packages/plugins wont support it. For mobile and console i think it matters to not fall too far behind
Using PlayerPrefs and set the amount of arrows you have in a hub world, and then after going into the first level a "Shooter" Script pulls the PlayerPref to set the current arrows equal to the PlayerPref, it looks like the PlayerPref is being set just fine but my shooter keeps saying I have 0 arrows available ```void Start()
{
currentArrows = PlayerPrefs.GetInt("Arrows");
} ``` Here is the start code for the Shooter for pulling the player pref, any help would be greatly appreciated
This isn't enough code to debug your problem.
Okay, what else do you need, I just dont know what else to show
'''public void BuyArrows()
{
if (coins > 0)
{
ArrowKepper.instance.IncreaseArrows(5);
ScoreCounter.instance.DecreseScore(1);
arrows += 5;
coins -= 1;
PlayerPrefs.SetInt("Arrows", arrows);
PlayerPrefs.SetInt("Score",coins);
}
}''' Here is where it is set in a Shop Script
And an explanation of where you're seeing 0 arrows
!code
๐ Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/, https://scriptbin.xyz/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
{
public static ArrowKepper instance;
public TMP_Text arrowText;
public int currentArrows;
void Awake()
{
instance = this;
}
void Start()
{
currentArrows = PlayerPrefs.GetInt("Arrows");
arrowText.text = "" + currentArrows.ToString();
}
private void Update()
{
PlayerPrefs.SetInt("Arrows", currentArrows);
}
public void IncreaseArrows(int v)
{
currentArrows += v;
arrowText.text = "" + currentArrows.ToString();
}
public void DecreaseArrows(int v)
{
currentArrows -= v;
arrowText.text = "" + currentArrows.ToString();
}
}
``` Here is the Arrow Kepper code which is set up in both scenes ```public class Shop : MonoBehaviour
{
[SerializeField] GameObject ShopMenu;
public int arrows;
public int coins;
public int cost;
// Start is called before the first frame update
void Start()
{
arrows = PlayerPrefs.GetInt("Arrows");
coins = PlayerPrefs.GetInt("Score");
}
// Update is called once per frame
void Update()
{
}
public void BuyArrows()
{
if (coins > 0)
{
ArrowKepper.instance.IncreaseArrows(5);
ScoreCounter.instance.DecreseScore(1);
arrows += 5;
coins -= 1;
PlayerPrefs.SetInt("Arrows", arrows);
PlayerPrefs.SetInt("Score",coins);
}
}
}
```Here is the Shop code which is only in the hub
private Vector3 mousePos;
public GameObject bullet;
public Transform bulletTransform;
public bool canFire;
private float timer;
public float timeBetweenFiring;
public int currentArrows;
public int value;
// Start is called before the first frame update
void Start()
{
currentArrows = PlayerPrefs.GetInt("Arrows");
mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>();
}
// Update is called once per frame
void Update()
{
mousePos = mainCam.ScreenToWorldPoint(Input.mousePosition);
Vector3 rotation = mousePos - transform.position;
float rotZ = Mathf.Atan2(rotation.y, rotation.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, rotZ);
if(!canFire)
{
timer += Time.deltaTime;
if(timer > timeBetweenFiring)
{
canFire = true;
timer = 0;
}
}
if(Input.GetMouseButton(0) && canFire && currentArrows > 0)
{
canFire = false;
Instantiate(bullet, bulletTransform.position, Quaternion.identity);
currentArrows -= 1;
ArrowKepper.instance.DecreaseArrows(1);
}
} ```And here is the shooter script
Where are you seeing 0 arrows
This is really sketchy
You have like 3 different variables tracking the arrow count
And the arrow keeper is setting the playerprefs every single frame with its version
Sorry a lot of code but that is everything related, I am seeing the Arrow Kepper showing current arrows above 0, but the public int currentarrows in the Shooter script shows 0 in the game
You need to have only one variable for the number of arrows
Yeah... I understand its defiently not the best, but it was working and then something changed but I dont remeber changing any code
You have 3 different variables and they're going to get out of sync
It's a recipe for disaster
Presumably the arrow keeper should be the source of truth
Get rid of any other variable that tracks arrows
And just always reference the arrow keeper when you need to access the current arrow count
Okay that makes sense, thank you!
Worked perfectly!
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[ExecuteInEditMode]
public class GenerateArray : MonoBehaviour
{
// This script only run in unity editor
[SerializeField] GameObject prefab;
[SerializeField] Vector3 offset;
[SerializeField] [Min(0)] int count;
private void Update()
{
#if UNITY_EDITOR
if (EditorApplication.isPlaying == false)
{
Refresh();
}
#endif
}
private void Refresh()
{
ClearPreviousIteration();
GameObject tempGameObject;
for (int i = 0; i < count; i++ )
{
tempGameObject = Instantiate(prefab, transform);
tempGameObject.transform.rotation = Quaternion.Euler(-90, 0, 0);
tempGameObject.transform.localPosition = (i * offset);
}
}
private void ClearPreviousIteration()
{
foreach (Transform t in transform)
{
DestroyImmediate(t.gameObject);
}
}
}
Hi, I want to create an editor script that generate array in editor. But when I use it, it has some error. It works fine when I increase the count, but it leave some 'residue' when I decrease count variable. The child is not destroyed as intended. How can I fix it? Any help is appreciated
[ExecuteInEditMode]
public class ContentParent : MonoBehaviour
{
public enum contentType
{
Text,
Password,
Account,
InputField,
Phone
}
[SerializeField] private GameObject[] prefabs = new GameObject[5];
[SerializeField] private contentType[] spawningElement; //in type
private void Awake() //on button pressed
{
float totalHeight = 0;
float margin = GetComponent<VerticalLayoutGroup>().spacing;
RectTransform contentSize = GetComponent<RectTransform>();
foreach (contentType element in spawningElement)
{
Instantiate(prefabs[(int)element], transform);
}
foreach (RectTransform element in transform)
{
totalHeight += element.gameObject.GetComponent<LayoutElement>().preferredHeight + margin;
}
contentSize.sizeDelta = new Vector2(464.5f + 838.5f, totalHeight);
GetComponentInParent<BasicDialogFrame>().RefreshSize(true);
}
}```
i want to add a button on the inspector, but if i extend Editor i cant use getcomponent, is there any ways to keep inspector GUI and this script in one piece?
DestroyImmediate will change your child count and corrupt the loop
Some reverse-for loop or ToList before deletion could work
ok i cant believe it must be two classes
[CustomEditor(typeof(ContentParent))]
public class ContentButton : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ContentParent parent = (ContentParent)target;
if(GUILayout.Button("Build Object"))
{
parent.onClick();
}
}
}```
as for the script , i put an execute in edit mode there
DONE
On a build of my game weird things are happening with the delivery/ shop system that doesn't happen in the Unity editor. For example you can continue to buy a stack of items that is already purchased, among other bugs.
What are possible reasons that can cause this (or any ) discrepancy between the editor and the build? That will help me out a lot in where to look for the bug.
hi there,
i wanted to make a productivity game where it requires the least amount of work to track your progress.
now, i just found out that unity isnt really capable of automatic startup/ running at background, so im trying to do it with raw code.
question is, im quite lost, as i dont know where to start. can anyone give me some small insights on where should i start?
uhm new errors while i updated it pls help @rigid island or someone else plssss help
did you remove the VC package
not really a code question
you can probably decrease the Default Contact Offset in the Physics tab
(this comes at higher cpu cost)
Ah true, will move the question
Thanks
advanced GUI coding topics
u see theres two buttons below, is there any ways to allow inspector to track whether objMapper has something in it?
i want to disable the "refresh UI" when objMapper has something, this is only editor mode scripts, so it needs to keep tracking in editor mode
- when objMapper is empty , enable Refresh UI button, disable refresh map UI button
- when its not empty, do the opposite
[CustomEditor(typeof(ContentParent))]
public class ContentButton : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ContentParent parent = (ContentParent)target;
if(GUILayout.Button("Refresh UI"))
{
parent.onClick();
}
if(GUILayout.Button("Refresh UI with map"))
{
parent.onClickWhenMapActive();
}
}
}```
ty๐
how can i store a static reference of a material? i tried to make a static class and use Resources.Load<Material>() in the static constructor but its not allowed and they advice to use awake, so is there other method i can use? or do i really need to have a monobehaviour for this?
btw this is only for edit mode not for runtime
this is not meant to go for the build, its only for development
then use the editor variant of that attribute, you can find it im sure
Or just make a property/function that will cache the ref on first get
i will have a look on that
Is this the correct way to calculate a child's world position after rotating the parent x degrees around its Z axis without actually rotating?
parent.transform.TransformPoint(Quaternion.AngleAxis(x, Vector3.forward) * child.localPosition)
Asset operations such as asset loading should be avoided in InitializeOnLoad methods
do a lazy load thing then so you load it once still
Looks about right to me. Try it out and see
i have a fog of war in my game where a black overlay covers the map. id like objects to be able to reveal areas based on some set values including a radius and the arc of the revealing shape. how should i go about this?
Sounds like a custom shader with masking on a black white texture to show/hide.
back then, when i was using the old input system...while using GetAxis, the rotation of cam used to be smooth..basically the value used to gradually increase and gradually decrease after no input is there...but now when i use the new input and calculating touch.delta, it is not that smooth.. i mean when i lift my touch, that gradual falloff is not there anymore...is there something i'm doing wrong?
the falloff is nothing, that is built in to the input system. You just get the values and have to store and increase/decrease them yourself to the level of smoothness you desire
Simplest would be to store the rawValue and have a lerpedValue that gets smoothed in some loop/update
how would i implement this
Fog of war is a common mechanic, they'll be loads of tutorials for doing it already
Even free assets in store already
Most likely, yeah !
the traditional way is just use a texture that you edit the alpha values of
otherwise stencils but I like the texture idea more
delete from here too.. and don't crosspost.
got an example of a response?
what class did you create soo far?
If you want to de serialize into a dictionary you want something better like json.net
Hm that should work ๐ค
May not be related but use UnityWebRequest
could be off the main thread causing an exception when using the unity api after (and tasks wont print exceptions properly unless using something like UniTask)
You could try changing the collection type from a List<T> to an array, the JsonUtility built-in library is very limited and is a reason most people prefer to use NewtonsoftJSON
hello
i wonder if it matters if you have the list not be null on creation?
it shouldn't as it says it uses the unity serialization but i cant think of anything else
then must fail at parsing somehow
Did you compare your data class being serialised to the JSON response from server?
Can you try to use your class instead of var?
they put the generic arg it wont matter
Ill test on my side
is this being tested via some mod or in a normal unity project? @swift falcon
Then probably caused by being loaded via this mod framework
guys, as I'm progressing with my game and adding more stuff, there's new inputs, events, etc that are detected via Update(), but now running all the stuff I have in the game in every single frame is starting to be a bad idea, but idk how I would handle these events in a more optimizated way. Could someone tell me how to do it?
FromJson() goes to some internal native function so Id guess how unity looks for types is not able to find this type and thus parsing fails
are you using the new input system with events being called instead of update checking for Input.keys ?
Your fix will be to try to include a better json parser like json.net. Can the mod framework include other .dlls ?
What is your data type when you log it, or is it probably null?
how is your mod code loaded then? surely other managed code can be added alongside it?
Or find some json parser you can include raw with your mod code
it's very complicated and i couldnt find somewhere that explains it properly, but yea it'd be great anyways. But there's still other things like collision triggers and etc
I am just wondering, isnt newtonsoft already part of unity anyways?
Ah, got you. Its not that complicated, and handling other events is always better layed out on paper before coding. write down your game mechanics and events, that happena nd go from there writing managers and correct loops for data handling
No, you can install it via GitHub from their package manager but they have removed it from their package manager I believe, which is bizarre
I think its an optional package but often included in projects now, could work!
Let me check on 6(2023)
its com.unity.nuget.newtonsoft-json
yeh, its just a standard package you can install and ship along
LitJSON is another good JSON library if you cannot go with Newtonsoft
Sorry wrong reply
depends what @swift falcon can include or use with this mod.
seeing if newtonsoft json was already in there to use would be best
I do a similar thing with my project where I have a .NET web API that connects to a MongoDB back-end but I haven't worked with BepinEx
Can you log your data type you get after the serialisation?
And when you use ToJson I guess your list is empty?
@swift falcon perhaps you can just slap the src for this in the mod. Otherwise see if you can have other dependencies go along with your mod code
https://github.com/dustyburwell/TinyJson
https://github.com/MessagePack-CSharp/MessagePack-CSharp
anyone use MessagePack for serialization?
yeah, i love it
just digging around about unity serialization system and thinking that there are better ways to serialize stuff
and that repo looks very good
Do you mean plastic SCM?
should i just dm you?
Depends on what you need it for. Networking, def. messagepack over other stuff.
i have very few complaints about MP in years of using it in games, the only thing that's problematic in unity is it can be fiddly to get the MPC code generator working for unity projects. there's a rosyln source generator now which is supposed to replace it but that doesn't work in my project for mystery reasons ๐
ye
ok so i did some stuff lemme dm you it is that alright?
ok so i havent done something like parallax in a long time and not surprisingly I've run into some weird behaviour. Basically I'm trying to get my hud to have a parallax effect depending on where the mouse is on the screen (This affects both position and rotation)
What I was expecting to happen:
- HUD to move and rotate based on where the mouse is on the screen
- Stay within the confines of the screen (this works)
What actually happens:
- HUD moves correctly but is very jittery
- HUD rotates incorrectly (the axis are mixed up I think) and also is even more jittery than the movement
the link leads to the code responsible for operating this and also attached is a 10s video of what it currently looks like
A tool for sharing your source code with the world!
hi does anyone understand conversion to quaternion and back to euler angles? I find it odd that if you convert euler 110,0,0 to quaternion and back you end up with 70,180,180!
Both of those sets of euler angles describe the same thing
This is why it's perilous to read Euler angles -- you can get surprising results if you try to look at a single axis
I believe they describe the same rotation, just with different steps. That's a big issue with Euler Angles, and something that's mitigated with Quaternions.
Generally you don't want to work with Euler unless strictly necessary. Converting back and fourth seems odd too.
thanks for the feedback, gonna add it to my tools list for serialization then
actually euler is nice and simple to understand for msot cases I find - only if you hit gimbal loc issues will it be a problem (and most games do not)
anyway seems the inspector does a magic trick to keep euler angles as simple as possible - discussed on forum but hard to follow
The inspector stores the euler angles you inputted so that it can show them to you later
it is a rabbit hole - Unity actually stores m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
(rather than converting quaternions back into eulers)
it is not the same transform.localeulerangles you read
I never work with Euler angles. I just use the Quaternion methods (e.g. Quaternion.AngleAxis) to construct rotations
I need to serialize rotation and seems less clean to serialize quaternion - does Unity not serialize euler?
euler angles are just a Vector3; you can certainly serialize that
One annoying thing about serializing a Quaternion is that the default value is [0,0,0,0] -- it's a struct, after all
this is an invalid quaternion
serializing Quaternions shouldn't have to be done unless you're a mathematics major.
ah Unity itself serializes the qauternion rotation and a euler 'hint'. How odd!
You probably don't want to edit them directly (:
well it is also less numbers to serialize
it'd be like exposing a Matrix4x4 instead of a position, rotation, and scale
oops meant to reply to the guy above that, that serializing a vector3 is less than quaternion
whats the intended way to deal with the fact that setting a value in the inspector is "volatile" in the sense that it wouldnt take much for that value to get wiped. I've got a class with 8 or so properties, and the safest thing for me is to figure out what value works right in the inspector, then I go and update the code itself to make sure that if I lost the inspectors settings, I wont actually lose anything
no dms sry. You can just send here np
version control
or copy paste the meta somewhere
if the numbers are fine to just assign in code, then i dont see an issue with that. if this were something else, like configuring stats across a bunch of different npcs, then you'd usually use scriptable objects.
in version control you'd easily see if u accidentally changed a value to a scriptable object. if you accidentally changed a component in a scene you most likely wont notice it. if its on a prefab maybe
version control isnt something I've actually looked into with unity
in the past I've only ever used git to commit stuff
in that case id worry less about the values in inspector, compared to the fact that you could lose your entire project unexpectedly
git is version control, and the best option to use
I'd probably be more worried about what else would be lost in the rare chance that the harddrive fails
I'll look into unity version control
tbh stick with Git. UVC is kinda horrid
theres many more ways that u can lose a project instead of the hard drive failing. it could just corrupt, or you could do something weird and a meta file breaks. its a real pita
Okay i invited my friend over but how do i connect my unity game with the plastic? please help me!!!
yeah the LFS was something I encountered before but I dont think the restrictions ever came up
cue meme : Aw shit here we go again..
another confusing moment brought to you by Unity VC โข๏ธ
Well, read above. Maybe consider using Git instead. I think there's a lot morer support in general when you use Git.
Unity VC is something I don't bother with because Git has existed since forever and I don't see a reason to suggest Unity VC over Git
surely UVC would deal with LFS without any extra effort right?
id be really curious how many people here can even help with unity VC in the first place, when i explored the options, there was no reason to use anything other than git.
barely
to whom is this responding
Dunno but Git LFS is not exactly hard to set up
"surely UVC would deal with LFS without any extra effort right?
"
ah
in GIT all you do is 1 command and its done
The only issue might be sizing, in which case I believe Gitlab has more space over Github but I can't confirm that
you might not even have to worry about large files tbh
gitlab indeed gives you more than github iirc
but could you tell me how he could work togheter, cuz we need to do the scripting AND the designing togheter
yeah it never came up, mostly as the projects have never been gigantic
it is if you don't read the instructions correctly
kablam
just dont drop all your assets into it
get on a discord call together, use Github desktop to push and pull changes
I just self-host a git server and shove everything directly into Git
biggest directory I ended up getting was be included in the .gitignore
you just download the already made gitignore. dont do anything weird yourself
The one case where I'm leery about "Just Put It In Git" is my substance painter files
those things are huge
keep big arts assets separate than VC. so no really need for LFS
yeah thats what I mean
I posted a video that explains how to use Git, which is very easy. Do note that regardless of the type of version control you use, you generally should not concurrently work on the same file or asset as it will introduce conflicts due to overwritten changes. Git actively avoids this and will end up requiring you to manually specify the correct version. Try working on separate files/scenes instead.
currently I just...don't version control those. Uh oh.
but isnt that kinda hard to do that the whole time ๐ญ cuz we need to work 160 hours on it toghether
that's a very specific requirement
you're still doing the exact same thing with UVC
ohhhhh
unity vc is not magic realtime collab
do you guys have any other program where it is easier to make a game on ๐ญ
works similiar to git
togheter
GitLFS still have problems with large pushes of data... ideally just keep the stuff local and use placeholders if it's large enough
that is the easiest
damm ๐ญ
even easier than that is you both working on the same computer
@junior dock Take a look at this video. It explains version control using, hosting your code/repo/game on GitHub through Git (two separate things), and if you're interested explains a GUI application called Github Desktop that allows you to combine the former two very easily with simple visualization.
this isn't a multiplayer game, its not trivial to connect them(unity apps) together properly without issues @junior dock
could we also share the same account so that we could work on it?
alr tysm
If you set up a Github repository correctly, you can use two separate accounts as collaborators. You should not use the same account. Just make sure the repository is private and just for the two of you.
but could this be an option
Context needed, there's very little reason to do this unless it's easier to write
Json is very easy, just takes more to write if you end up having to do lots of manual labour
Have you been using JsonUtility or Newtonsoft?
i'm not sure how a modding framework would have anything to do with parsing json
Well there's your problem. Try switching to Newtonsoft
Most likely JsonUtility can't deserialize it
JsonUtility has some important limitations
note that we can't really help you with modding here
You can load dll files. Try loading a .NET Standard 2.0/2.1 compatible version of Newtonsoft
yeah for one JsonUtility doesnt handle props or dictionary and anything unity cannot serialize
and this is a great example of why
it creates really weird problems that make no sense in the context of normal game development
nah go and use one of the 1000 different "its no different to json but the dev wanted to try and fix json" json alternatives
Ah yeah, Bepinpex is modding.