#archived-code-advanced

1 messages · Page 51 of 1

misty glade
#

why are you loading terrain in a spiral..?

dusty wigeon
#

For aesthetic purpose

misty glade
#

so you can load a limited amount of it at once..?

placid shell
dusty wigeon
#

I at least, that it is what I concluded

misty glade
#

aesthetics is one thing, load "denormalization" is another

dusty wigeon
#

Yeah, exactly what I was saying earlier.

#

Could have been by distance or chunck

misty glade
#

you should fully load the terrain using a lightweight object of some sort as one thing (and be concerned with aesthetics there) and load the heavy objects separately (and be concerned with performance there)

#

those things are two different problems, you're .. maybe mashing them into one

placid shell
dusty wigeon
#

To come back with the previous topic, you use 1 as base case. The rest is like resolving a series.

misty glade
#
private Dictionary<(int, int), TerrainTypeEnumOrSimpleClass> _data; // <-- populating this is instant for pretty much anything up to zillions 
private Dictionary<(int, int), GameObject> _unityData; // <-- populating this is very slow

public class TerrainTypeEnumOrSimpleClass // <-- not a monobehaviour
{
  public TerrainTypeEnum TerrainType;
  public float Height;
  public int Weight;
}
placid shell
#

ok, i think i understand? so (frames - 1)**2 + 1, and if that is equal to something, then turn, and then I don't know....

dusty wigeon
#

Not really sure why we have frames there.

placid shell
misty glade
#

sure, fine, whatever 😛

placid shell
placid shell
dusty wigeon
#

What you are expecting in performance ?

dusty wigeon
#

previous 0

misty glade
#

just saying, figure out your terrain first using POCOs, render/load it separately depending on .. whatever. What the user is facing, how far they can see, how much memory/cpu your game objects take to interact, etc.

dusty wigeon
#

Plain Old C# Object, if you did not know

placid shell
misty glade
#

maybe you should show some code..

placid shell
misty glade
#

maybe that's the problem then 😛

placid shell
misty glade
#

10k GOs is no big deal

dusty wigeon
#

Start at:
Previous Sqr: 0
Next Sqr: 1

Previous Sqr + 1 Turn
Previous Sqr + (Next Sqr - Previous Sqr)/2 Turn
Increment Next and Previous Sqr

misty glade
#

I mean, it's a lot, but .. it sounds like what's much more likely to be the culprit is something else in the spooky code

placid shell
# misty glade 10k GOs is no big deal

i use entities instead, cause you can have even more entities than game objects (I probably should have mentioned that I'm using ecs and dots for most things, sorry....)

misty glade
#

still fine

dusty wigeon
#

You really made me do it. I won't do anything else though. You figure out how to translate in position.

placid shell
misty glade
#

If you're having performance with 10k objects you're really likely doing something else that isn't obvious to you that's killing your performance.. rendering your gameobjects in a spiral or in a limited fashion is A) going to be hard for you and B) probably not the problem

dusty wigeon
placid shell
dusty wigeon
#

It could look cool. See everything just come from the sky and form the world in a spiral.

misty glade
#

Sure, it could be that as well, but designing some convoluted system to load "when the player isn't moving" is surely a recipe for spaghetti.

dusty wigeon
#

Yeah, you would need a second system for whenever the world is actually loaded.

misty glade
#

To reiterate: this is probably the issue. I'd bet a dollarydoo on it.

placid shell
placid shell
#

and what would i do with these step1 and step2 then?

#

I ain't clever lol

placid shell
placid shell
ember temple
#

This seemed pretty fun to try out. There’s a rule of math that a square root of any integer will never be perfectly between its upper and lower square.
So take the number 13 and square root it. Ceil and Floor it. Now figure out if it’s closer to its ceil or it’s floor. If the closest square is ceil and even number go left. If it’s closest square is ceil and odd, go to the right. Likewise, if it’s closest square is floor and odd go up, and if it’s closest square is floor and even, go down. You’ll have to save your previous position but this should tell you whether to add/sub the x or y.

13 square rooted for example is 3.78. The ceil and floor is 3 and 4. It’s closer to 4 and 4 is even. therefore go left (minus 1 on x).

placid shell
placid shell
ember temple
#

somewhat visualized

placid shell
ember temple
#

those are the squared numbers, i just boxed them to help me think 😅

placid shell
#

oh ok cool

austere jewel
plush hare
#

No text channel for dots?

#

Have to create a big glamorous forum post?

austere jewel
plush hare
#

there she is

austere jewel
#

(the first pinned forum post)

arctic lake
#

Is there any code that allows me to check if my player has this option enabled

arctic lake
#

Thanks!

regal olive
#

hello all, im currently experianceing 3 errors saying that the XRSocketInteractor dose not contain a definison for GetCurrentSocket ,isSelected, andGetAttachedObject when useing the XR Interaction toolkit package in unity3d, did they change the names of these? or are they not a thing to begin with? and if thats the case how would i go about makeing them? code here:https://codeshare.io/oQZmlB

regal olive
#

opps my bad sry

sage bolt
#

if I have an object implementing two interfaces, class myClass : interfaceA, interfaceB, in a function in interfaceB would (this is interfaceA) evaluate to true when run? could I then do (myclass)this in interfaceB?

#

sorry if this isnt advanced, still learning how to properly use interfaces

dusty wigeon
#

Not clear. Can you elaborate ? in a function in interfaceB would (this is interfaceA) evaluate to true when run?

#

From what I understand, you are not using interface in the correct way...

sly grove
#

unless it's a default implementation?

dusty wigeon
#

It would work, in theory though.

sly grove
#

It seems like a bit of a code smell to me TBH

dusty wigeon
#

In practice, you would want to redo your code pretty fast.

sly grove
#

what's the goal of this

sage bolt
#

hold on, ill go write it out and provide a more detailed explaination

dusty wigeon
#

Try to stick to concrete example.

sage bolt
#

im trying to make an interactable interface that the player can call the oninteract method when pressing a button. The default implementation should be to check if the class implementing oninteract is an inventory, and if so run a function on the player to show ui

#

im wondering if in the default implementation of oninteract in the interactable interface i can do if (this is inventory) and then use player.showInventoryUI( (inventory)this );

#

is that an okay approach to this?

dusty wigeon
#

The inventory is interactable ?

sage bolt
#

yes all inventories are assumed to be interactable

dusty wigeon
#

Why are you just not overriding the function ?

sage bolt
#

inventory is also an interface

#

i was thinking it would be easier to assume the norm for interactable is an inventory and do default method there, and for buttons and things like that override it

dusty wigeon
#

Do a graph.

#

I'm not following the dependencies

#

I think that, there is something that is not working here

sage bolt
#

on it

#

many things are interactable, but im assuming most will be inventories, so the default should be inventory

dusty wigeon
#

Makes an abstract class for Inventory instead of an interface.

#

In the class, implement the onInteract.

sage bolt
#

better graph:

sage bolt
dusty wigeon
#

Why ?

sage bolt
#

the modloader im using has to package it to be an interface to properly compile

#

all interfaces are part of a custom assembly shared to modders

dusty wigeon
#

Use composition over hierachy then.

sage bolt
#

I am

#

most inventories are also destroyableObjects

#

this is just a basic graph of interactable heirarchy only

#

I was thinking it would be easier to have interfaces more specific than interactible so I wouldnt have to re-setup inventory every time

#

I guess it would be better to put a default implementation of oninteract in inventory rather than interactable, as well as the other interactable interfaces

dusty wigeon
#

Inventory must be a class to implement something.

#

Hence an Abstract class.

#

What I am talking about composition over heritance is:
Instead of implementation the "OpenInventory" in each class (Chest, Body, etc.), you implement it in an "Action" that you reuse it.

#

This way, you do not need to re implement everything in each class.

#

If you push this all the way. You have only 1 concrete class (Interactable) that have multiple action and behaviour implemented as action/effect.

undone coral
# sage bolt all interfaces are part of a custom assembly shared to modders

don't overthink this. do this instead

interface IInteractable {
 bool opened { get; set; }
 void Use();
}

// an example where both opened and use make sense
class Door : MonoBehaviour, IInteractable {
 public bool m_Opened = false;
 bool opened {
  // put the door opening animation here
  get => m_Opened;
  set => m_Opened = value;
 }
 void Use() {
  opened = !opened;
 }
}

// an example where only Use makes sense, to mean
// "start a conversation with"
class Guard : Npc, IInteractable {
 // not used for anything, but implemented
 bool opened { get; set;}

 void Use() {
  StartConversation();
 }
}

// an example where only opened makes sense
...
class InventoryItem : MonoBehaviour, IInteractable { ...}
class Chest : InventoryItem {
 bool opened { ... }

 // left empty
 void Use() {}
}
#

does this make sense? you don't need a hierarchy of interfaces

#

it does nothing for you

#

every kind of interaction you suppose should go into IInteractable

#

this this is for a mod, i understand that you must use interfaces

regal lava
#

You can always mix and match interfaces too; don't necessarily need to derive from them.

undone coral
#

this makes sense, they are for things where you can not modify the code

#

don't mix and match interfaces

#

declare 1 interface

#

put all the methods you "need" in the interface

#

it's an interface, it's not a hierarchy. it's an adapter. it's a way to translate from one thing to another

#

does this make sense?

sage bolt
#

you guys are right ive been thinking about this wrong

undone coral
#

look at my snippet

#

i believe you must use an interface because that's what the mod system requires, for good reason

regal lava
#

My code base is fine with mixing interfaces. Say you have an interact interface, but I don't want to interact with my NPCs. So, by mixing them I can interact with some npcs or not.

undone coral
regal lava
#

If it's pointless then c# wouldnt let you inherit multiple interfaces

#

and stuck to 1 class 1 interface rule

dusty wigeon
undone coral
#

@sage bolt focus on my snippet

#

do you see the insight there?

sage bolt
#

yes its very helpful

#

im seeing if I can adapt it

undone coral
#

so we've eliminated IButton, INpc, IInventory

sage bolt
#

I want to implement a bunch of objects that are both InventoryItem and IInteractable, so it seemed a waste to rewrite it every time

#

but I think i know what to do

undone coral
#

try to merge the methods declare in those all into IInteractable, and then, when things sound like they have overlapping meaning (like Use and StartAConversation could both be just Use)

#

combine them

undone coral
#

which i assume needs to know some kind of methods for turning a pointer click into a method call on a script

#

that's all it should do

sage bolt
#

I guess I was looking for a way to have a class implement something that just set up a predesigned implementation of both interactable and inventoryitem

undone coral
#

you're focusing on the wrong part of the snippet i guess lol

#

i modified it

#

i think people shove things into the right side of the : all the time

#

it's not super clear yet what your goals are

#

what it sounds like is there is a pre-existing IInteractable declared by the game

#

and you want to use it somehow?

sage bolt
#

yes?

undone coral
#

what does it actually look like

#

you create a DoorInteractable : MonoBehaviour, IInteractable, and it has a reference to a Door, and you're done

#

you build prefabs

#

it's hard to say

sage bolt
#

well the idea was basically have an class Inventory : IInteractable then class smallChest : Inventory, class largeChest : Inventory, but im forced to use interfaces by modloader

undone coral
#

there's a lot of context missing to give good advice

sage bolt
#

thats why I had interface implementing interface

undone coral
#

it sounds like you didn't know that

#

in the declarations you just made

sage bolt
#

I did, but I wanted to share the inventory class with modders, which has predefined implementation of the OnUse function

#

also share NPC class and Button class with predefiend OnUse

#

but must use interfaces...

#

I need to restructure

undone coral
#

if the modloader needs you to have an interface declared for every class

#

so it goes

#

you can't make it any easier for people, other than maybe writing your own mod loader

#

it has nothing to do with your structure

#

if people can't handle doing that, they're not going to be able to use your toolkit

#

@sage bolt put another way, you can't take this from "1" coding knowledge required to "0". you're only taking it from "103" to "102", which isn't so meaningful

#

i wouldn't sweat it

#

when you say share with modders

#

i mean this is all very confused...

#

i am starting to understand what you are trying to do

sage bolt
#

sorry about that

sage bolt
#

ive been trying to make it as simple on modders as possible

undone coral
#

so here's what you're trying to do

#

you're trying to make a toolkit for modders

#

their mod would have a dependency on yours

#

you want to share things like an inventory item implementation

#

but unfortunately the mod loader only allows sharing interfaces between dependencies

#

great

#

i have a lovely solution for you

sage bolt
dusty wigeon
#

I usually roll with an architecture like that. This is what I am talking with Composition over Inheritance.

sage bolt
#

I was sharing dlls directly to modders

undone coral
sage bolt
#

oh ok

undone coral
#

and it sounds like they can't access the classes

#

is that the issue?

#

they can't just inherit from your Inventory class

#

because of limitations in the mod loader or something?

#

or can they? in which case this is a moot point

sage bolt
#

yes, the modloader is limited, cannot share classes only interfaces

undone coral
#

okay

#

i mean can they call static methods?

#

that are declared in another mod?

sage bolt
#

they can access and call functions on classes from other mods, but not inherit them

undone coral
#

this affects how verbose this is

sage bolt
#

inheritance I need to do interfaces

undone coral
#

great

#

i'm not quite sure why it can't be inherited, i'm sure there's a good reason

#

but then this can be done with

sage bolt
undone coral
#

// your prebuilt behavior (example)
sealed class DefaultInteractable : MonoBehaviour {
 public IInteractable target { get; set; }

 void OnClickHandler() { 
   ...
   target.Use();
 }
}

// a modder's code
class Button : MonoBehaviour, IInteractable {
 public void Start() {
  var defaultImplementation = gameObject.AddComponent<DefaultInteractable>();
  defaultImplementation.target = this;
 }

 void Use() { ... }
} 

interface IInteractable {
 void Use();
}
#

@sage bolt do you see?

sage bolt
#

ohhh i think i understand now

#

so a modder has a custom implementation of IInteractable, and this script has that as its target

#

or I can use my predefined ones

undone coral
#

you can turn

  var defaultImplementation = gameObject.AddComponent<DefaultInteractable>();
  defaultImplementation.target = this;

into

void Start() {
 AddInteractableBehaviour(this);
}

...

interface IInteractable {
 void Use();
 Component self { get; }
}

public static DefaultInteractable AddInteractableBehaviour(IInteractable target) {
 var impl = target.self.gameObject.AddComponent<DefaultInteractable>();
 impl.target = target;
 return impl;
}
#

yes

#

your problem is basically "all classes in other libraries are sealed"

#

that's the most accurate way to describe the underlying issue

#

you can work around that though

sage bolt
#

right that makes sense

#

I wasnt thinking about it like that

#

I could even have some of the interfaces just be components now that I think of it

#

Thanks for all the help!

undone coral
#

@sage bolt yes, and since you have static methods, which are easy to use

#

for normals

#

you can build around that

#

see the updated snippet

#

you can use the interface to force the end user (the modder) to conform to what a button needs to do

#

you can do this a lot of ways

#

very reasonable use of an interface

#

you're one of the only people using interfaces for what they are actually meant for btw @sage bolt

#

99.999999% of people having issues with them in this chat use them in ways that don't make sense

#

it is a Bad Idea to declare function properties (like UnityEvent) on your sealed class ... : MonoBehaviour and have users assign those instead

#

assigning functions is reinventing interfaces

sage bolt
#

thats good to know!

frank peak
#

most people probably aren't programmers and just want to "make a game", which, fair, but it does mean we see a lot of it here in code-whatever

undone coral
#

or something similar

sage bolt
#

I was thinking of making inventory a component but the more I think about it the worse it is. your solution is great for allowing modders freedom.

undone coral
#

you can make an sealed class InventoryUIActions : UIBehaviour and it takes a IHandlesInventoryUI interface in a property

#

and the modder implements "just" the methods in IHandlesInventoryUI

#

this is how UGUI works isn't it? you've seen these patterns before

#

the reason interfaces crop up in all these places is because interfaces are meant to answer the question:
"what if you can't possibly know what all the code is going to be ahead of time?"

#

they aren't meant for "organizing a programming project" or "adding structure"

sage bolt
undone coral
#

you will also maybe see that things that take an IInteractable as a target might themselves be something like

#
interface IHasInteractable {
 IInteractable target { get; set; }
}
undone coral
#

and maybe you want to make that generic...

interface IHas<T> {
 T target { get; }
}

interface ICanAssign<T> : IHas<T> {
 T target { get; set;}
}
#

what does this look like?

#
interface IProvider<T> {
 T instance { get; }
}

interface IHost<T> : IProvider<T> {
 // really TrySetInstance
 void Inject(T instance);
}
#

here's another way to look at it

#

this same stuff by a different name

#

there are also dozens of people who post about dependency injection here

#

and it makes no sense

#

but when you're authoring mods and plugins it does!

#

that is what it is meant for. when you can't possibly know what all the code is going to be ahead of time

#

whereas, in your own game and your own codebase, you can always know all the code ahead of time

#

so it's pointless

#

you can modify anything, and change the access level of anything. if something is sealed, you can go and remove that keyword. so it's pointless. @regal lava

sage bolt
#

that makes sense

undone coral
#

in my opinion, you probably do not want to create a dependency injection framework

#

keep it as simple as possible. don't use the generic interfaces

#

and stuff like that

#

it will intimidate people

#

carefully choose static methods

#

with clear names and simple arguments

#

and encourage people to use that as the API

#

unity is already a dependency injection framework, Inject is AddComponent and GameObject is an IHost

#

and IProvider is GetComponent

#

that's why you don't really need to author a whole dependency injection framework

#

you can use interfaces here to reduce the amount of bugs

regal lava
#

It's hard to avoid the dependency injection stuff since monos are done using Unity's constructor. I've ran into this issue multiples times and still scratching my head about keeping some data completely private from other modules.

undone coral
#

unless you are authoring a plugin or library, private is documentation. the access modifiers have this weird thing with the inspector by idiosyncrasy, but they are really documentation in your own code base

regal lava
#

May got to get back to you on that, I was developing some tool on the gui and couldn't wrap my head about some accessor privilege's when trying to nest multiple classes.

undone coral
#

yeah it's pretty arcane

#

i'm not saying declare everything public and use class instead of struct

#

they have functional impacts, sure

#

but using them as access modification alone is documentation. you can always change the access modifiers

sage bolt
#

Interactable class and interface for has interactable```cs
public sealed class IInteractable : MonoBehaviour
{
public Func<InteractInData, InteractOutData> InteractionAction;
}
public interface HasInteractable
{
public IInteractable interactableTarget { get; set; }
}

#

then an inv interface

public interface Inv
{
    public List<Item> items { get; set; }
    //can be overridden if a modder wants their inventory to be set up different by default
    public void SetupDefaultInteractable(IInteractable interactable)
    {
        interactable.InteractionAction = data => 
        { 
            //default show inventory stuff goes here
            return new InteractOutData(true); 
        };
    }
}
undone coral
#

it's redundant

sage bolt
#

oh yeah

undone coral
#

this si going to work poorly

sage bolt
#

silly of me

undone coral
#

you did exactly what i said not to do lol

#

very very bad

#

lol

#

just stick to the snippet i shared

#

trust me it's the best approach

sage bolt
#

I was thinking raycast can just look for interactable and call it

undone coral
#

no

sage bolt
#

ok will redo it

undone coral
#

also you declared a default implementation in an interface

sage bolt
#

in line with snippet

undone coral
#

which is not allowed

#

i mean this thing you shared won't compile

#

okay, before you do anything more

#

carefully reread everything i wrote lol

#

and if you have any questions please ask them

#

you sort of have to understand 90% of what i wrote before you embark on the rest of this journey

sage bolt
undone coral
#

this is the snippet i am referring to

#

this is the way

sage bolt
undone coral
#

it might support them in unity 2023.1.0a but i don't think you are using that

#

so either you're not using the code you posted, you are misreading the messaging from unity and haven't yet discovered it doesn't work, or i am wrong

sage bolt
#

I misread, ill redo it one sec

undone coral
#

don't

#

try to fix it though

#

use the snippet i shared

sage bolt
#

use these two for handling interaction calls

public sealed class InteractableHandler : MonoBehaviour
{
    public IInteractable target { get; set; }
    public void OnClickHandler(InteractInData data)
    {
        target.Use(data);
    }
}

public interface IInteractable
{
    public void Use(InteractInData data);
}
#

I can just look for InteractableHandler when raycast or something like that

#

inventory and data is this

public struct InteractInData
{
    public GameObject caller;

    public InteractInData(GameObject caller)
    {
        this.caller = caller;
    }
}
public interface inventory
{
    List<Item> items { get; set; }
}
#

I did one thing different though that im wondering if is okay or terrible

#
//modder made class
public class smallChest : MonoBehaviour, IInteractable, inventory
{
    public List<Item> items { get; set; }
    public void Awake()
    {
        var handler = gameObject.AddComponent<InteractableHandler>();
        handler.target = this;
    }
    public void Use(InteractInData data)
    {
        //GenericFunctions.ActionDict["default inventory"](data);
        Debug.Log("default inventory function not implemented")
    }
}
/* unused 
public sealed static class GenericFunctions
{
    public static Dictionary<string, Action<InteractInData>> ActionDict { get; private set; } = new Dictionary<string, Action<InteractInData>>()
    {
        {"default inventory", data => Debug.Log("default inventory function not implemented") },
        {"default buttom", data => Debug.Log("default button function not implemented") }
    };
    public static bool AddEntry(string name, Action<InteractInData> action)
    {
        if (ActionDict.ContainsKey(name))
            return false;
        ActionDict.Add(name, action);
        return true;
    }
}*/
#

to allow modders a default function to pull from instead of writing their own

#

have a static dictionary of predefined functions

#

also if a modder wants to add a bunch of interactables that all behave the same, instead of rewriting it they can add it to the dictionary and reuse it

undone coral
#

i think you're still pretty confused

#

addcomponent doesn't appear anywhere here

#

you're still declaring functions and assigning them to variables

#

you're too preoccupied with making the api "and then your thing : IInteractable" and that's it. it's impossible to just do that alone

#

next snippet you share, write in a comment which code is yours and which code would be the modder's

#

and declare everything that is sealed sealed

#

so that you can wrap your mind around this better

sage bolt
#

is this not the same as snippet with one change?

#

smallChest implements the Interact function from the IInteractable interface

#

but instead of defining it there it pulls from preset functions

#

i changed without dictionary active, is that still different from snippet? I add the interactableHandler in awake of smallchest and set target, and implement the IInteractable.Interact void

#

I'm sorry if im missing something

sage bolt
undone coral
undone coral
#

InteractableHandler is mean tot be all the "Defaults"

#

like nobody wants to write their own click handling codew

#

you are saying "defaults" and reall yhtat's just, i don't know, the meat of your plugin

regal olive
#

Hi all, i got a problem with the unity event system to find a game object, if i do "itemToDrop = EventSystem.current.currentSelectedGameObject.GetComponent< ...>" then he find the GameObject, but if i do "GameObject.Find(EventSystem.current.currentSelectedGameObject.ToString())" then he does not.. anyone got an explanation please ?

undone coral
#

everyone is going to have a different Use implementation, nothing "Default" should appear in there

#

does that make sense? @sage bolt

#

so Use is strictly the stuff that is special about the end user's inventory item

#

you can add useful utilities (like static functions) that people can call from Use

sage bolt
undone coral
#

okay

#

but read carefully what i am saying

sage bolt
#

im reading and responding to all give 1 sec

undone coral
#

an empty Use ought to be valid

#

no problem

#

like Use that is empty would be an item that when clicked in the inventory, does nothing

#

and gets spent

#

does that make sense?

#

it would be "Potion: Does nothing."

sage bolt
#

ohhh

undone coral
#

InteractableHandler would contain everything you are calling "default"

#

you say default

#

you're still thinking in radioactive class hierarchy terms, where that word isn't used anywhere anyway

sage bolt
#

right

undone coral
#

default is a made up chembot idea

sage bolt
#

so all default interactable general stuff goes there

undone coral
#

purge your mind of this word default

sage bolt
#

ok so no default at all

undone coral
#

lol

sage bolt
#

what im thinking is this

undone coral
#

i know

#

yes

#

i understand what you are saying

#

you can say "Basic" instead of "default"

#

a basic implementatino of an inventory item, you click on it, it spends 1 quantity, it casts a spell

sage bolt
#
public void Use(InteractInData data)
{
  GenericFunctions.ActionDict["basic show inventory function"](data);
  //special specific to this class modder function
}
undone coral
#

the spell is implemented in Use

#

nooooooo

#

stop with the actiondict!!!

#

look at what you have

sage bolt
#

should modders not have access to a generic show inventory function without having to code it?

undone coral
#

look at OnclickHandler

#

why would they call that?

#

you would put that in OnClickHAndler, and also, why is it an action dict? why isn't it just a static function?

#

anyway

#

i gotta go

#

you have used up all your doctorpangloss points lol i'm sorry

sage bolt
#

sorry about that

undone coral
#

it's okay

sage bolt
undone coral
#

i think as you improve in C# a lot of this will be obvious to you

sage bolt
#

ill try

#

I assumed that all inventories modded or not would call a similar base show inventory ui function then add custom stuff from there hence the dictionary

#

sorry for wasting so much of your time on this

undone coral
#

it is incomprehensible to me why you are doing GenericFunctions.ActionDict["basic show inventory function"](data); instead of InventoryItems.ShowInventory(data);, where ShowInventory is a static method

#

but nevermind that you don't need that at all, in this psecific case

#

Use wouldn't have ShowInventory, i mean

#

i don't know

#

okay

sage bolt
#

yeah sorry

#

ill do some research and testing on my own. thanks for all the help and snippets

sage bolt
regal olive
#

but the ToString give me the exact name

#

i used a Debug.Log and it shows me what i want

sage bolt
#

didnt for me

#

tostring adds (UnityEngine.GameObject) on the end

regal olive
#

for me it's both the same.. lol

sage bolt
#

?? then neither should work

#

can I see the debug.log code

regal olive
#

yeah

sage bolt
#

Debug.Log(teste);==Debug.Log(teste.ToString());

#

Debug.Log(teste.name); is what you want

regal olive
#

oh... hold one a second

#

oh yeahhhhhhhhhhhhhhhhhhhhhhhhhh

#

got it thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

sage bolt
#

np 👍

plain abyss
#

I've got an object pooling system that uses classes that implement an interface I made that has a Reset function, so I can have different objects reset different fields when they get disabled by the pool. If I use extension methods to add a Reset function to, for example, Transform, is there a way I can make it "implement" the interface and be a valid sub-type for the pool? I don't want to just use SendMessage or reflection, if it comes to that I'll just check the type before calling the function on it and drop the type requirement on the generic

thin mesa
# plain abyss I've got an object pooling system that uses classes that implement an interface ...

You wouldn't really be able to make a type implement an interface without being able to modify the actual type so that wouldn't really work. You could instead go the route that unity's built in ObjectPool went and just accept delegates in the ctor for the actions to take when getting/returning to pool. Then you wouldn't need any constraints on the type and your pool would work for any type

plain abyss
#

I could, but I liked the idea of the interface instead of the delegates just for the sake of my own OOP-poisoned brain grokking it better. If I have to use delegates I'd probably just switch back to Unity's built in

#

The whole point was to make one I didn't need a bunch of delegates for

#

Guess I just discovered why it used em in the first place then, might as well switch instead of repeating mistakes of the past

undone coral
craggy sierra
#

hmm, so my game has a pause menu with a host and a client button, when i press the host button (obviously starts hosting, im using netcode btw), and then close my menu too fast, it crashes the built version but NOT the editor version. looking at the player log shows that it crashed ofc, and then it says that it fails to get the stacktraced debug symbols. this is the actual log (minus the massive loaded binaries list and other stuff at the top)

  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFA64DC6A7D)
0x00007FFA64DC6A7D (UnityPlayer) (function-name not available)
0x00007FFA65AD07BF (UnityPlayer) UnityMain
0x00007FFA65ADA53D (UnityPlayer) UnityMain
0x00007FFA65ADA635 (UnityPlayer) UnityMain
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFA64D1889A)
0x00007FFA64D1889A (UnityPlayer) (function-name not available)
0x00007FFBABBA26BD (KERNEL32) BaseThreadInitThunk
0x00007FFBAC60A9F8 (ntdll) RtlUserThreadStart
#

any ideas how I can debug what's happening if my stacktrace isnt even working?

#

and yes i selected development build

#

also the stacktrace changes for some crashes apparently

dusty wigeon
#

Do you have a crash dump ? Do you have the symbols associated ?

craggy sierra
#

crash dump yes

#

symbols no clue

#

i assume no because it cant read them

#

no clue how to check tho]

dusty wigeon
#

They should located with the build you did or in the StagingArea after a build.

dusty wigeon
#

In temp folder, after a build.

craggy sierra
#

appdata temp or windows temp

dusty wigeon
#

Unity temp

craggy sierra
#

never heard of that, is that in my project folder or some folder i dont know about?

dusty wigeon
#

Project Folder

#

You need to have done a build without closing Unity

craggy sierra
#

i see a managedsymbols too

#

should i look there or stagingarea

dusty wigeon
#

Yeah

#

Look there.

#

What is your platform ^

craggy sierra
#

this folder is empty

#

windows 11 64 bit

#

you need specs or

#

i imagine not for binary debugging like this

#

stagingarea has data folder

#

lib_burst_generated.pdb

#

i imagine thats what i want

dusty wigeon
#

In PC you usually have BackUpThisFolder_ButDontShipItWithYourGame

craggy sierra
#

yes i have that too

dusty wigeon
#

and the symbols are there

craggy sierra
#

well

#

not backup

#

i have libburst somethig something

#

hold on

dusty wigeon
craggy sierra
#

_BurstDebugInformation_DoNotShip

#

thats what i have

#

in the game folder

#

lib_burst_generated.pdb is what i want i imagine

dusty wigeon
#

Do you use Mono or IL2CPP ?

craggy sierra
#

mono

dusty wigeon
#

I use IL2CPP. Not sure where the symbols are with Mono.

craggy sierra
#

how do i use the symbols tho

dusty wigeon
#

Not really something I am an expert in.

craggy sierra
#

its a pdb file right

dusty wigeon
#

Yes

craggy sierra
#

its easy to switch the IL2CPP for a quick build

#

i can do that if you want

dusty wigeon
#

You open your crash dump with Visual Studio

craggy sierra
#

whats the difference?

dusty wigeon
#

Il2CPP is faster runtime

craggy sierra
#

by how much

dusty wigeon
#

I mean, everything that is faster is better.

craggy sierra
#

sure

#

how do i load the symbols

dusty wigeon
#

It could help you

craggy sierra
dusty wigeon
#

Can you screen shot the whole

craggy sierra
#

the whole?

dusty wigeon
#

Is that the whole screen ?

craggy sierra
#

what else do you want

dusty wigeon
#

I usally have an action like that

#

Maybe just try to launch debug from the menu

#

Then something like that

craggy sierra
#

i dont see an "Actions" menu

dusty wigeon
#

And, I've look and you need to have "Copy PDB files" checked

#

Just start the debug as you would do normally

craggy sierra
craggy sierra
#

i dont have a lot of experience debugging in VS

dusty wigeon
craggy sierra
dusty wigeon
#

What is the file you are opening ?

craggy sierra
#

crash.dmp

dusty wigeon
#

I just have Switch crash dump on hand

#

Do not really know how to help there.

#

Normally you have those action

craggy sierra
#

oh yeah i see those

#

oh

#

thats the actions area

#

after opening it

dusty wigeon
#

🤦

craggy sierra
#

but i reopened my file just now

#

so when i was talking earlier there was no actions

dusty wigeon
#

Ok, so you did click on debug

craggy sierra
#

yeah but i just randomly picked one of the 3

#

im gonna run mixed i think?

#

hold on

dusty wigeon
#

You need the .pdb of Unity I think.

#

Which should be in the editor folder

craggy sierra
#

what the

#

i added the unity pdbs selection on that unity debugging article you linkedf

#

idk if thats what i need

#

but now i need this extendedatomcops header

dusty wigeon
#

Do not go anyfurther

#

You have an issue in Unity code.

craggy sierra
#

is that why this shows

#

because the stack frame pointer is in this header?

dusty wigeon
#

What your callstack looks like now ?

craggy sierra
#

or in an object file that needs that header

#

i can scroll more if you want

#

interesting

dusty wigeon
#

You have everything you need

craggy sierra
#

so mixed was the right option

#

cool

dusty wigeon
#

I usually do not go further

craggy sierra
#

stack frames are so fun to look at lol

dusty wigeon
#

Not really

#

😦

craggy sierra
#

i disagree.

#

IMO debugging stuff is so much fun, i didnt realize VS supported debugging this well

dusty wigeon
#

Say that in a couple of hour.

craggy sierra
#

haha

#

ive made an OS kernel before

dusty wigeon
#

I'm sure you gonna have a lot of fun with this bug.

craggy sierra
#

trust me ive had my fair share of debugging stack traces

#

idk that im GOOD at it

#

but its fun

#

.

dusty wigeon
#

Anyway good luck

craggy sierra
#

what am i supposed to do, just send it in to unity

#

or do i go apply for a job at unity 👍

#

debug it there with access to the entire source

dusty wigeon
#

You minimize your code/scene till you do not have the issue

#

If you look a bit higher. You might be able to have more information. I've to do this for Partcuticle Effect and Cloth at some point.

#

You remove every particule effect

craggy sierra
dusty wigeon
#

till you find the one

craggy sierra
#

this is the top of the stack

#

external code

#

hmm

craggy sierra
dusty wigeon
#

Work from there

craggy sierra
#

k

#

will do

#

thanks

snow flint
#

hi guys, im not looking for a detailed solution or answer here but more just general advice... i have a turn based 3d grid based multi level game with A* pathfinding. I also have an 'enemy intent' system (similar to slay the spire) where it shows the player where each enemy is going to move next turn or do x action on what unit etc.

im having performance problems with pathfinding as i update each enemies intent (next action they will do) after the player does an action or ends their turn, as the enemy intent system checks every possible spot the enemy can move to and evaluates how close it is to its target player

i did make some performance improvements by switching from classes to structs for my pathfinding implementation but its still quite slow, im hesitant to take the dive into using jobs as it requires a large refactoring and im not 100% sure if it will solve the problem

code for move action, every valid gridposition is fed into this method everytime the player takes an action

    public override EnemyAIAction GetEnemyAIAction(GridPosition gridPosition)
    {
        Unit targetUnit = unit.GetEnemyAIUnitTarget();
        GridPosition targetGridPosition = targetUnit.GetGridPosition();
        int pathLength = Pathfinding.Instance.GetPathLength(gridPosition, targetGridPosition);
        int pathLengthValue = 100 - pathLength; // invert pathlength so we get the lowest value, which is the best path

        return new EnemyAIAction
        {
            gridPosition = gridPosition,
            actionValue = pathLengthValue,
        };
    }

is anyone able to give me some advice on how to start thinking about and solving the performance problems? (performance problem = the game 'lags' for ~1s when youend your turn or complete an action)

glossy harness
#

Hey guys, I'm trying to make a minimap rendertexture, I had it working earlier but now I want to use a shader to render my texture and its showing up as dark red in the game view, however when I look at my scene view everything is fine.

#

Even during play the scene view is totally fine

#

the same texture in game view

#

btw im using shader graph to write the shader

undone coral
#

this is such a simple minimap you don't need to do anything sophisticated

glossy harness
#

but I wanted more flexibility on how to render it

untold moth
craggy sierra
#

@dusty wigeon so apparently if i remove all my trees it stops crashing

#

BUT

#

i dont know if thats a race condition or something

#

it might not be related to trees

#

but i have 10000 trees

#

and its always crashing on a draw call afaict

hardy sentinel
craggy sierra
#

no

#

im in a forest

#

smh

hardy sentinel
#

do you ever see 10000 trees in the camera, tho?

hardy sentinel
#

then yes

craggy sierra
#

i am NOT writing a script to move the 10000 trees around

hardy sentinel
#

is it more problematic than a game that crashes? xD

craggy sierra
#

anyways it shouldnt CRASH from having too many trees

#

they have LOD

#

so it shouldnt be a problem

#

and its only if i close my menu fast after starting a netcode host

#

its a weird bug

#

pretttttttty sure i dont want to just delete some trees and let it marinade in my game code

hardy sentinel
#

do you happen to completely sync 10000 trees? 😛

craggy sierra
#

no

hardy sentinel
#

phew 😄

craggy sierra
#

they dont have network objects or anyhting

#

and again

#

its only when i close my menu quickly

#

if i close it after a few seconds, it works completely fine

hardy sentinel
#

that's so weird

craggy sierra
#

my best guess atm is some really weird race condition where the frames my netcode starts running, the code has to handle input

hardy sentinel
#

still you shouldn't have 10000 anything in your scene at the same time 😛

craggy sierra
#

its literally the default for mass place trees

#

so

#

anywayts

hardy sentinel
#

the standard is either the UnityEngine.Terrain Component, Chunks, or custom GPU stuff

craggy sierra
#

?

#

anyways my guess is something in my input handler does not like something in my netcode

#

well its not my netcode

#

it IS my input handler

#

but i dont know how to tell if thats true

#

whoops

#

how do i print what thread im running on so i can compare in my debug crash dump?

untold moth
#

Thread.CurrentThread?🤔

craggy sierra
#

yes

glossy harness
#

How can I pass a texture that I created during runtime to shadergraph for sampling

#

I've created a minimap texture during runtime, but I want to do some post processing on this texture using a shader

craggy sierra
#

guys have i mentioned how simple race conditions are to debug

#

i added debug.log()s

#

and now it wont crash

#

yep

#

this is brilliant

hardy sentinel
hardy sentinel
#

shadergraph is just a shader creator, you don't actually mess with shaders in runtime (not in normal use cases)

glossy harness
#

its not a static asset, I create this Texture2D during runtime and I also update it

hardy sentinel
#

instead u should feed data to the material that uses that shader

glossy harness
#

I see

#

I have a list of vector3's on a game object, would it be possible to pass these to the shader during runtime? And if so what node would that be

untold moth
glossy harness
#

ok well how would I get a reference to this texture

#

I can expose it as static on the game object

craggy sierra
untold moth
untold moth
craggy sierra
#

ok so how do i debug a race condition

#

or figure out if it is 100% a race condition

hardy sentinel
#

check the crash logs?

craggy sierra
#

what logs

#

they just say "Crash !!!"

#

and then a bunch of binary names

#

and then a list of errors where it failed to read the stack trace

untold moth
#

They should give a reason of a crash.

#

Some kind of error or error code

#

And probably a stack trace.

#

Probably also worth looking at the player log.

craggy sierra
#

im in the crash_ folder

#

but the only log in it is the player.log

#

and then a memory dump

untold moth
#

Is that from a build?

craggy sierra
#

yes

#

it only crashes on build

untold moth
#

I guess there isn't a crash log then...🤔

glossy harness
craggy sierra
#

we already told you

untold moth
craggy sierra
#

this is the best ive got (from the crash dump on VS)

#

and the stack is like this

glossy harness
craggy sierra
craggy sierra
#

and anyways, thats not hard

glossy harness
#

Ah

#

yes

#

I forgot about materials

#

thanks for clearing up my brain fart

craggy sierra
untold moth
# craggy sierra

Not 100% sure, but are you calling some unity API from a thread perhaps?

craggy sierra
#

i mean like

#

i would tell you

#

but my debug.log() stops the crash

untold moth
#

Anything but the main thread.

untold moth
craggy sierra
#

im not explicitly using another thread, but there is netcode and the input system

#

that might use another thread

untold moth
craggy sierra
#

not entirely sure on the thread architechture of unity, i probably should be if im gonna keep dealing with race conditions

#

yes

untold moth
craggy sierra
#

wdym

#

like a callback from netcode?

untold moth
#

Like where is it called from?

untold moth
craggy sierra
#

uh, so im calling NetworkManager.Start_Host() from a button press, and im calling some code to close my menu in a key press

hardy sentinel
craggy sierra
#

i wish i had nitro for that emote but i assume most people know it

hardy sentinel
#

tf TF ?

untold moth
#

Honestly, I don't think it's a race condition

craggy sierra
craggy sierra
hardy sentinel
#

trollface 👍

craggy sierra
#

👍

untold moth
#

But we can't really tell for sure without any details.

#

Need to see the log.

craggy sierra
#

what details are you looking for, or what details should i find

#

what log tho

#

the crash one?

untold moth
#

Yes

craggy sierra
#

because again it doesnt crash in the editor

#

also

#

i think the stuff you said earlier is in my crash dump

untold moth
#

What platform are you building for btw?

craggy sierra
#

windows 64bit

untold moth
#

Okay.

craggy sierra
#

this is the error code

#

from VS

#

reading my crash dump

#

and its in some graphics callback

#

well

#

idk about callback whatever

#

doesnt matter its a function

#

and thats where it is in the stack trace, in every single crash

untold moth
#

It sounds like unity's thread safety system. But we don't know what the cause is.

#

This is not the log though. What do you see in the log?

craggy sierra
#

i dont know how im supposed to get to the log

#

also after i checked "Copy PDB files" in build settings my player.log actually does have a stack trace but its just like in the call stack in my crash dump

#
========== OUTPUTTING STACK TRACE ==================

0x00007FFA694C649D (UnityPlayer) BufferD3D11::EndWrite
0x00007FFA694BAFA3 (UnityPlayer) GfxDeviceD3D11Base::EndBufferWrite
0x00007FFA692C6A7D (UnityPlayer) GeometryJobTasks::EndGeometryJobFrame
0x00007FFA69FD07BF (UnityPlayer) GfxDeviceWorker::RunCommand
0x00007FFA69FDA53D (UnityPlayer) GfxDeviceWorker::RunExt
0x00007FFA69FDA635 (UnityPlayer) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FFA6921889A (UnityPlayer) Thread::RunThreadWrapper
0x00007FFBABBA26BD (KERNEL32) BaseThreadInitThunk
0x00007FFBAC60A9F8 (ntdll) RtlUserThreadStart

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

if you want it

untold moth
# craggy sierra

From the stack trace it looks like it's trying to write to a buffer. If that's where it crashes, perhaps the buffer is not available on the thread... I'm not sure why that would happen though.

dusty wigeon
#

@craggy sierra, you still like debugging ?

craggy sierra
#

i just am not good at it

craggy sierra
#

a massive hunk of a list of loaded binaries

#

dlls msotly

dusty wigeon
#

What happens if you reduce or increase the amount of tree ?

untold moth
craggy sierra
dusty wigeon
#

Does the error goes away ? Does it amplify ?

craggy sierra
#
Crash!!!
SymInit: Symbol-SearchPath: '.;C:\Users\a\Documents\Debug Hunted;C:\Users\a\Documents\Debug Hunted;C:\WINDOWS;C:\WINDOWS\system32;', symOptions: 534, UserName: 'a'
OS-Version: 10.0.0
dusty wigeon
#

Which line cause the crash ? Is it when you open the menu ?

craggy sierra
dusty wigeon
#

Do you instantiate your menu ? Or you keep it alive ?

craggy sierra
#

menu is controlled throuhg .active

#

or whatever

dusty wigeon
#

Do not need a that to know which line cause an issue.

#

Delete everything till it works

craggy sierra
craggy sierra
dusty wigeon
#

Then readd everything till it does not work

craggy sierra
#

but i need trees

dusty wigeon
#

What shader are you using ? What batching technic are you using ? What tech are you using ?

#

Did you try to swap your tree for something else ?

craggy sierra
#

not sure about batching technique

dusty wigeon
#

Is it only this particular object ? Is it the material ?

craggy sierra
#

not sure what you mean by tech

dusty wigeon
#

What rendering path are you using ?

craggy sierra
#

forward

dusty wigeon
#

URP ?

craggy sierra
#

the shader is a shader that ships with the trees but i had to edit it a bit to actually work

#

urp

#

yes

dusty wigeon
#

Did you try to remove the SRP

craggy sierra
#

for some reason the shader still had "lightweight" instead of "universal"

dusty wigeon
#

Can you try to use the standard ?

#

For test purpose

craggy sierra
#

and i dont think it will build

#

which i need to repro the crash

dusty wigeon
#

It should not and if it does, it will still build

craggy sierra
#

will it tho

#

i can try

dusty wigeon
#

For tree, you normally use GPU Instancing

craggy sierra
#

yep

#

there are three kinds of tree

#

in my scene

dusty wigeon
#

Is it one kind that is problematic ?

craggy sierra
#

idk i can test that before throwing out URP

#

but i dont even know if trees are the problem for sure, just the problem stops i remove them

dusty wigeon
#

There is a lot of tree, maybe it is link to the number of objects rendered.

#

Which is why I'm thinking about the SRP.

#

And batching.

craggy sierra
#

i tried adding 10000 cubes and it did not crash

craggy sierra
#

number of objects i mean

#

and i dont want it to

dusty wigeon
#

Maybe there is race condition in the SRP.

craggy sierra
#

if i have high object count it should just run at 1 fps

dusty wigeon
#

Unity is code.

#

Code is not perfect.

craggy sierra
#

but

#

it could also be anywhere else

#

why does it hapenn

#

SPECIFICALLY when i close my menu quickly after opening a host for NGO

#

idk it could be either way

#

SRP or my own code

dusty wigeon
#

Because you are changing the graphics load.

craggy sierra
#

ok one type of tree crash

dusty wigeon
#

Are you instancing your menu ?

craggy sierra
#

now to test the others

craggy sierra
dusty wigeon
#

Do you keep it alive ?

craggy sierra
#

yep

dusty wigeon
#

Or your Destroy it

craggy sierra
#

it stays alive

dusty wigeon
#

Did you try to destroy it and instancing it back. You shouldnt do that, but for test purpose.

craggy sierra
#

no it has a lot of weird references

#

i have to refactor a bit so it can be added as a prefab for any level

dusty wigeon
#

!Unclean Code Detected!

craggy sierra
#

very true

dusty wigeon
#

Did you try to show up other piece of UI instead of your menu ?

craggy sierra
#

ok tree type 2 crashed

dusty wigeon
#

Try something else than a tree after.

craggy sierra
#

hmmm, like what

dusty wigeon
#

Unity Cube would be the best

#

with the default everything

craggy sierra
#

how do i mass place cubes tho

dusty wigeon
#

Like you do with your tree...

craggy sierra
#

maybe it wasnt working because i was trying other meshes

#

idk i tried other stuff earlier

austere jewel
#

I'm unsure whether this is really an #archived-code-advanced topic, but it's going on long enough that you should make a thread for it anyway!

craggy sierra
#

k all trees crash now to try cubes

#

alright

velvet mirage
#

Is there a way to obtain the vertexes of an edge that a raycast2D intersects?

untold moth
#

Or whatever stores the vertices in this case?🤔

velvet mirage
#

Physics2D.raycast doesnt have any overloads that output hitinfo it seems

untold moth
wooden cedar
#

Bloop bloop, realized you were talking 2D 😄

austere jewel
#

Raycast returns a RaycastHit2D, it doesn't provide that info and you would have to calculate it yourself afaik

velvet mirage
#

that kind of sucks, is there a way you'd suggest for me to calculate those points?

austere jewel
velvet mirage
#

that sounds like extremely large overhead for what i'm trying to achieve

#

I need these vertexes so i can allow my player to move in a path traced along a composite collider, iterating through the edges to find the correct one would be a ton of overhead to run every frame for my player's movement logic

untold moth
velvet mirage
#

Composite colliders and edge colliders already store their edges in an array, the issue would be obtaining the correct edge index based on position; any solution I’ve come across there just involves iterating through every edge, but the composite collider in question is my level geometry, it would be a lot of overhead

untold moth
#

Maybe use a quad tree?

rare mortar
#

when i throw my rope using line randerder in my first throw my my rope comes from the (starting point (the point where my line randerder is on the ground ) )or may be from another side .
after retracting back and using again makes it fixed..
anyone got an idea what's going on.

after retracting and using again making it fix.. (Perfectly)
i've tried caling retracting in start in case it fix but not working

i have
Starting Point
End Point

in First throw it comes my rope goes create from the my hand but a line actually moving from ground to my end point

novel meteor
#

Need help with my "grid" object placement system.

I have "top walls" & "bottom" walls. When placing in some directions, they randomly change to "top wall"

I use "OverlapBoxAll" to detect objects closes, change to other sprite depending on if it has an object below or above.

I've tried messing with directions for a while now.

(Putting code in thread)

thorn flintBOT
#
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.

rare mortar
fresh salmon
#

That's not what the code posting instructions say, try again

#

Mobile users cannot see the code without downloading it

rare mortar
rare mortar
fresh salmon
#

You read the instructions of the bot above

rare mortar
#

ohh 1 sec

dusty wigeon
rare mortar
dusty wigeon
pale zinc
#

Anyone here good at networking stuff?
I'm building an app on iOS that needs to communicate with the Unity Editor (a custom editorwindow). I need to be able to send files from the editor to the app and vice versa. I also want to do some RPCs from the editor to the app.
What's the best way to go here? I came across the Telepathy library which makes it easy to set up a connection and send arbitrary byte arrays over tcp, but I'm not quite sure how I would figure out what file I'm sending/receiving (a header, probably?).
Or is it a good idea to run a small http server on the app and use UnityWebRequest for sending files?

frank peak
#

man I am sorta regreting this decision to implement my own input field class

#

totally didn't consider the selection caret lol

#

and my brain is not working this morning

undone coral
#

lol

frank peak
#

Im building a code editor in-game and the input field was acting like a scroll rect when I was trying to use a parent scroll view

#

either way the solution felt janky so it was a choice between jank and jank

#

cuz I want the line numbering and input field bound to the same scroll rect, so I just sort of made my own input field class to handle input

undone coral
frank peak
#

really?

undone coral
#

with line numbering

frank peak
#

F

undone coral
#

i don't remember it being this complicated

#

what is your goal?

#

why do you need an in game code editor

frank peak
#

I was building a digital circuit simulator, its more a passion project then anything honestly, its not a big deal really heh 😅

#

and wanted to make a code editor to complement things I guess?

undone coral
#

oh yeah

#

that's right

frank peak
#

tho honestly maybe a selection caret is the real test here. If i want to tackle stuff like code completion at some point, maybe I need to do this hurdle heh

undone coral
#

you will learn something more useful in the long run if you embed a web browser in a ugui rect, and host the code editor inside there

#

UGUI and UIToolkit aren't really suitable for building text editors

frank peak
#

Mmm I see

undone coral
#

and by more useful, i dont' mean 20% more useful

#

i mean more like 10,000% more useful

#

right now you're clicking on the corpse, and you have two items to loot and only one space in your backpack:

  • the parts for building your own code editor in ugui
  • an embedded browser

and the game is rendering embedded browser with rainbows and holograms and animated particle effects and shit, and its legendary rarity hue is such a deep purple that it created a void in your screen. whereas the parts of building a code editor have like, a little fly circling around like it was a pile of poo

#

@frank peak does that make more sense?

frank peak
#

lmao fair ye

scenic forge
#

If you go with embedded browser approach, you could just use VS Code for the web and you get all VS Code features for free without you needing to write a single line of code; alternatively you can use one level under which is Monaco editor (which powers VS Code under the hood) and at least get things like syntax highlighting line numbers autocomplete for free.

#

Or you can just expose the file directly and let user choose whatever code editor they want to use.

undone coral
#

you can open up your mind to ways to build a circuit simulator more dearly

undone coral
#

i only use an in game code editor for literally receiving copied and pasted text

#

there's a lot of value in going from 1 code to 0 code, but not much value in going from 102 code to 101 code

scenic forge
#

I mean if the game is centered around letting players to code, I’d like to let players use whatever code editor they prefer than forcing something on them.

#

I’d much rather opening it in VS Code and have all my extensions and keybinds to work comfortably, than whatever in game code editor you force onto me that probably works very wonky and unpleasant to use.

frank peak
#

hmm good points but I also am leaning towards forcing the players hand into this jank

scenic forge
#

It's always a trade off, players tabbing out of the game to edit code breaks game immersion, but so does player getting frustrated at the code editing rather than enjoying the problem solving.

undone coral
#

surely if it's a game, you should be using blockly (there is a UGUI based asset and also official blockly embedded in a browser) or a limited-syntax coding tool (like a node based graph, although i personally really dislike those)

#

👀

scenic forge
#

With limited information, I would do:

  • Design the language in a way that it can be coded comfortably without the assist of an IDE. Obviously it shouldn't be whitespace sensitive like Python; reduce the need for punctuations especially bracket pairs like (); linear code top to bottom flow, so no need for player to "jump to symbol" around; short keywords eg fn/func instead of function.
  • Offer a super basic in game editor, could be as basic as literally just a multiline input field.
  • Also offer editing outside using your own editor. It can be done as simply as "when player tab out, write the code from memory to file; when player tab back in, read from the file to memory" that's trivial amount of code with decent enough UX.
undone coral
#

but that's just my opinion

#

recreating fusion360 and eagle, and then also turning it into a game, is hard

frank peak
#

yeah thats fair. its fairly silly to try this but eh its not a serious project but just something to experiment with more or less, to learn and stuff. Thank you for the suggestions Burrito, Ill keep that/them in mind.

mental mesa
#

Hi there, I am implementing object pooling and I am trying unsuccessfully to Release all objects in my pool using thePool.Clear() et .Dispose(). Have I missed something ?or misunderstood how it works ?

thin mesa
mental mesa
sand acorn
#

hello there, does anyone know how to get sqrMagnitude of a float3? "mathemathics package"\

sand acorn
regal olive
#

How do you use Unity API from another thread which isnt the main thread? I have found https://stackoverflow.com/questions/41330771/use-unity-api-from-another-thread-or-call-a-function-in-the-main-thread and it seems that the first answer works for people but I want to know if there is any simpler method

novel plinth
#

you'd need to make your own thread dipatcher

#

just use jobs instead of rolling your own tbh

compact ingot
austere jewel
glacial wedge
#

I have a problem:
I have a gameobject hand that has a rigibody, I want it's children (fingers) to trigger but if I had rigidbody on fingers the hand lose it's behaviour

#

fingers colliders are not trigger, and I want that triggers with in scene trigger collider without rigidbody

#

Trigger happens only if one of the 2 colliding colliders has a rigidbody, right?

#

the fingers rigidbody prevents the hand rigidbody to work properly (using the fingers collider as combined collider)

craggy spear
#

Rigidbody takes events from colliders on the same object and children

glacial wedge
#

I'm thinking about possible solutions:

  1. fingers without rb. add rb to scene gameobject that have to interact with trigger.
  2. dupplicate the fingers so I can have one with rigidbody that makes the trigger happen and the other without rigidbody to gives hand's rb to work correctly.
  3. fingers with rb. somehow makes the child rigidbody stop prevents the hand (it's parent) rigidbody to work.
  4. fingers without rb. somehow know from with finger collider the trigger happen.
  5. fingers without rb. somehow trigger enter only when the hand enter and not for each finger
glacial wedge
#

the problems come from that if I have only the rb on hand it fires the trigger for each finger

torpid smelt
#

Hello. I'm currently trying to modernize a screenshot tool that's part of the build process to be automatic. This is going alright, but the screenshots I'm getting from it are significantly darker than what I actually see in playmode/the old screenshot system. Any advice? The settings on the cameras used are exactly the same. My current suspect is that the color mode on the render texture's inaccurate, but I don't know what it should be for a usecase like this

#

the dark one's the current output, and the lighter ones are examples of how it shows up in the old system/in the editor

glacial wedge
#

The OnTriggerEnter(Collider other) method gives the "other" collider (the scene gameobject which i'm interacting with) so there is no way the finger will know it

dusty wigeon
#

Yeah, true

glacial wedge
#

the other behaviour is that the vr hand collides with object pushing it on the wall without cross it when the player moves the vr controller in his real space

#

to have a good precision with the hand I need to place colliders into fingers

#

but with triggering gameobject in scene i gets triggerenter and triggerexit for every finger, instead i want only one

dusty wigeon
#

Can you just keep track of how many finger have enter and just fire the event if there is none ?

glacial wedge
#

I'll try. good tip

#

it works like a charm

#

@dusty wigeon thanks

dusty wigeon
#

Beware of when objects are being destroy/disable, if I remember correctly they do not fire OnTriggerExit.

undone coral
#

you are probably using automatic exposure

#

i'm not sure if that exists for URP if this is a URP pipeline game

torpid smelt
undone coral
#

okay that was my other guess lol

#

the api should really give you the texture format that is appropriate for the color space, rather than making you choose between sRGB and UNORM

undone coral
#

any suggestions for runtime texture manipulation libraries? my goal is to easily crop and resize textures performantly. for example, i'd like to zoom-to-fit an AOV to a specific size.

midnight violet
undone coral
undone coral
# midnight violet Do you really need to change the texture or do you just want to show it cropped?

it looks likely i will put this all into a custom pass, but i'm wondering if there are already utilities for simulating the various camera croppings. for example, if the player's viewport is 300x500, and i need a 400x400 square image, i'd want a letterboxed/pillarboxed source from the center of the 300x500 viewport (a 300x300 source) copied to the 400x400 frame. i understand i can achieve this at the finest level using the graphics pipeline commands, but i'm wondering if there's already an expressive way to do "blit letterboxed/pillarboxed"

vale spindle
#

how to code a* stairs/slopes pathfinding?

dusty wigeon
vale spindle
#

i'd say discret and it does include vertical pathfinding

dusty wigeon
#

So it is a space game ?

#

Are you character grounded ?

#

Or they fly ?

vale spindle
#

i want to have units that can fly later, but i'm trying to start with simple things

#

so yes the character is grounded

dusty wigeon
#

If it is discret, just change the neighbourhood of the nodes around the stair

vale spindle
#

i dont want to do it by hand, what algorithm should i use?

dusty wigeon
#

Use the navmesh of unity ?

undone coral
vale spindle
#

i cant use unity's thing because i have my own movement script

dusty wigeon
#

You still can use Unity's.

vale spindle
#

okay i 'll learn about nav meshes and come back

undone coral
midnight violet
glossy harness
#

Hey guys, I'm trying to add multiplayer to my game. I have a gameobject with a rigibody, network object, network transform, and a network rigidbody. I'm currently sending the player inputs over a ServerRpc, but I'm running into this weird issue where My movment works as expected when I run my server in the editor, however once I try to run my server as a dedicated server my movement seems very slow and jittery.

any ideas as to why this could be happening?

#

I'm using multiplayer tools to run the server from unity editor, and I'm compiling for a standalone dedicated server to run it outside of unity.

grand vale
#

Im trying to make a inventory system, I have a inventory array that holds all the item data and the imaginary slots, but idk how I can pair the lets say 3rd inventory slot UI with the 2 index in the array. (Also the amount of inventory slots determined till the game is ran)

undone coral
#

big picture

glossy harness
# undone coral what is your goal?

Im creating a racing game with server authoritative physics

My “racer” is a cube that I apply a force to using a UI joystick.

Ive been noticing some really weird discrepancies between running my server and client in the editor and running a separate dedicated server (compilation target) and a standalone client.

undone coral
#

does your journey end with a graphically polished multiplayer game?

#

there are a lot of things that could be going on, including some configuration here and there, differences between reality and expectations, etc.

glossy harness
#

yes this is for a startup I am working on, I have about 1-2months of experience with unity, but overall 5 years of professional dev experience

undone coral
glossy harness
#

Somewhat yes

#

but its quite flexible

undone coral
#

is the primary purpose to have a game, or something else?

glossy harness
#

both kinda

undone coral
#

i am trying to figure out what mutliplayer thing to suggest

glossy harness
#

the game is just a aspect of the platform

undone coral
#

and i totally understand the magnitude of jeopardy you might be in lol

#

okay

#

and i also totally understand the lack of focus

glossy harness
#

the overarching platform is a competitive crypto gaming platform

undone coral
#

lol

#

yes

glossy harness
#

yeah

undone coral
#

lol to your emoji

glossy harness
#

ive looked at PUN