#archived-code-general

1 messages ยท Page 140 of 1

leaden ice
#

All TMPro components derive from MonoBehaviour

#

why do you want it to be a MonoBehaviour though

raven cove
#

Maybe I'm misunerstanding I appologise I am a noob. I just want to read what buttons are being pressed in the\ input field on another script that is all.

leaden ice
raven cove
#

Because I could access the variables on that script?

leaden ice
#

any component

#

regardless of whether it's a MonoBehaviour

raven cove
#

I added public variables on the TMP_Inputfield and I couldn't find them

leaden ice
#

how do you add variables on TMP_Inputfield?

#

Are you trying to modify Unity's built in classes?

leaden ice
#

so you'd have to also modify the custom inspector

#

but really

#

you are definitely going about this the wrong way

#

there is no need to modify the input field code

raven cove
#

okay I appologise I guess I am too in over my head

leaden ice
raven cove
#

Is that the "OnValueChanged" event?

#

Okay I think I see now

shell scarab
#
public class WeightedList<T, W> where W : IComparable, ICollection
```How do i implement `ICollection` and not have it apply to W? I tried:
```cs
public class WeightedList<T, W> : IComparable, ICollection, where W : IComparable
```but the compiler doesn't like that.
somber nacelle
#

remove that last comma on the second line.
it is public class WeightedList<T, W> : IComparable, ICollection where W : <whatever constraints>

shell scarab
#

oh, thanks

daring cove
#

Hey,
Im getting this error when trying to build an asset bundle
No AssetBundle has been set for this build.

public class CreateAssetBundles : MonoBehaviour
{
    [MenuItem("Assets/Build AssetBundles")]
    static void BuildAllAssetBundles()
    {
        string assetBundleDirectory = "Assets/AssetBundles";
        
        if(!Directory.Exists(assetBundleDirectory))
        {
            Directory.CreateDirectory(assetBundleDirectory);
        }
        
        BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows);
    }
}
rain minnow
leaden ice
ionic socket
#

async/await question. I have SelectionManager class that I invoke which includes a Task that I then await in my code. I want to be able to pass in a method through the constructor that I can call and await before setting the result on the Task. I can pass in a method as a System.Action<T> just fine, but that can't then be awaited. Anyways, the question boils down to, how can I pass a method as an argument that can be awaited?

cobalt gyro
#
        {
            checkmark = transform.GetChild(0).transform.GetChild(0).transform.GetChild(0);
            checkmarkToggle = checkmark.GetComponent<Toggle>();

            descriptionTextTransform = GameObject.Find("Weapon Display Info").transform.GetChild(0);
            descriptionText = descriptionTextTransform.GetComponent<TextMeshProUGUI>();  
        }``` I hate myself
#

Is there a better way of doing this

ashen yoke
#

when you sub a method of a struct that is a member of a class to an event, what exactly is happening?

swift falcon
cobalt gyro
ionic socket
ionic socket
cobalt gyro
ionic socket
#

for the toggle, that's internal

#

description text, you can simply use Find(<magic string>).GetComponentInChildren<TextMeshProUGUI>() and based on how you have it here, it'll always grab the correct one.

ashen yoke
#

and then just GetComponentInChildren

#

or, if its a prefab, make root component that stores references for prefab internals

ionic socket
#

what I would typically do is have WeaponDisplayInfo be a class, which has it's own variables that stash the descriptionText and do a FindObjectByType<> rather than Find.

ashen yoke
#

have

    public struct ValueRef<T> : IDisposable
    {
       public event Action<T> onValueChanged;

its a member of a class

private ValueRef<bool> _ref;

in init

void Start()
{
    _ref = new ValueRef<bool>();
    _ref.onValueChanged += Method();
}

result - subscription happens, then .. unhappens.
delegate is null after some point, i cant track it down even with debugger atm
as soon as struct is changed to class, delegate stops losing reference
what exactly is going on here?

pine perch
#

hi, if i instanced an animation clip, how can i save it with code so it would work even on the build version of the game

ashen yoke
#

any ideas are welcome, its either a bug in clr or i dont understand something

rain minnow
cobalt gyro
#

im only going to need 1 reference so that wont be necessary

simple edge
# ashen yoke any ideas are welcome, its either a bug in clr or i dont understand something

http://kosiara87.blogspot.com/2011/11/cnever-place-event-inside-struct-c.html?m=1
It seems this post ran into the same issue when placing an event in a struct.
They provide a couple of theories why this occurs

lean sail
#

ah that link suggests the same

ashen yoke
#

i understand that something there is somehow related to copy semantics but the struct is a member of a class, accessed and written into as a member shouldnt that avoid unnecessary copies? Also this theory would suggest that structs are immutable which they arent, and that any assignment to any field copies, and ref keyword on structs is pointless

olive silo
#

how can i add "roll" to my camera? or more generally, how can i rotate a transform about the axis that it's pointing in?

#

i know i'd need to do some quaternion stuff, but i suckk at quaternions.

ashen yoke
#

one rolls, one yaws one pitches

#

one for distance

#

one for vertical offset

#

and the root at the character feet

#

oh and one for camera mount point, so that it snaps to its position/rotation instead of direct parenting

olive silo
#

i'd really prefer to do it the quaternion way ๐Ÿ˜…

ashen yoke
#

ah forgot about springs

olive silo
#

in my head it makes a lot more sense to just picture it as a look-at camera with a rotation about its forward vector, and i'd like my code to reflect that.

#

i already use Transform.LookAt() to look at my player's transform, now i'd just like to add rotation about the camera's forward vector.

latent latch
#

Do you mean to revolve a camera around a point?

mellow sigil
#
transform.Rotate(transform.forward, amountToRotate);
olive silo
#

๐Ÿคฏ

latent latch
#
    public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
    {
        return Quaternion.Euler(angles) * (point - pivot) + pivot;
    }
olive silo
#

thank you

latent latch
#

this is pasted everywhere

#

but that with lookat

olive silo
lean raptor
#

Yo anyone that knows scriptableobjects well, i have an issue where when I close unity and reopen it, my scriptableobject references all disappear, here's the script: https://pastebin.com/P6J9FC3F
(yes there are a lot of redundant ScriptableField attributes, was trying to see if that fixed it, it didn't. I also had my objects originally instantiate themselves directly in the declaration, like public List<QuantumPrefabLink> RealmQuantumLinks; = new List<QuantumPrefabLink>(); but I thought that may be whats clearing it.. didn't seem to be.)

Please help!

#

The entirety of it gets reset, even a color field. I don't get whats happening.

cosmic rain
lean raptor
#

it is, gotta scroll down, there's just multiple classes defined there

#

do I have to do EditorUtility.SetDirty(scriptableObject) if I'm changing values from another editor script?

cosmic rain
lean raptor
#

I'll try editing it through the editor and see if holds the ref

#

easy test i guess

cosmic rain
#

Generally, what you're editing is an instance loaded into the memory, not the actual file. When editing via code, you need to tell unity that it needs to save the changes to the file. Set dirty should work I think.

lean raptor
#

Hmm but the changes definitely appear in the editor

#

so it just won't actually save it unless I mark it dirty for when I close

#

what a strange behaviour

#

as if I'd want the alternative like tf

cosmic rain
#

Yes, because the editor is viewing the object in the memory.

carmine umbra
#

anyone know how to add a space between the bars in the code?

lean raptor
#

I'll try it out n see

carmine umbra
#

I configured the x,y,z positions and speed but I dunno how to add space between

cosmic rain
# lean raptor well fuck

If you use SerializedObject and SerializePtoperty in your custom inspector, then unity would handle the changes automatically. Otherwise you need to mark them as dirty.

lean raptor
#

SerializedObject on what exactly, the entire scriptable object or the references?

#

I was using SerializedField n wasnt doing anything

#

apparently it's the same as marking it public too

cosmic rain
#

It should be used for the references I think. Haven't messed with editor scripting that much.

lean raptor
#

so if in that code I put SerializedObject around my types it should save it?

#

I'm not doing any editor scripting really

#

its just the scriptableobject

#

I have some code running that generates it using a contextmenu

#

but I will be moving to editor script

cosmic rain
#

You said that you modify them via code though?

lean raptor
#

ya just a context menu on a gameobject

#

which runs at editor time i guess

#

not technically editor scripting but i guess any scripts running at editor time is an editor script lmao

#

anyways I did a test to manualy edit the values

#

reloaded unity

cosmic rain
#

Try the SetDirty then.

lean raptor
#

and it kept the data

#

so it most definitely is this issue

#

looks to be fixed, thanks @cosmic rain

nimble stream
#

this is super weird does anyone know why this is happening

winged mortar
nimble stream
winged mortar
#

Oh wait its a video

nimble stream
#

yea

winged mortar
#

Okay so an if statement without curly braces

#

And then a statement

#

Will be interpreted as a if with a single line in there

nimble stream
#

i tested it with a simple print too though also

devout knoll
#

Hello guys, where is the best way to ask for help, but not code wise, more about Unity - Xcode compatibility

winged mortar
#
if(something)
    Debug.Log("something");
nimble stream
#

yeah i did that too and it still happened

winged mortar
#

Is the same as

if(something)
{
  Debug.log(something)
}
#

What you did

#

By removing that statement

#

You will always call the next line which is something like list.remove()

#

Please don't send videos in the future

#

They are awful to look at for code

nimble stream
winged mortar
#

Code please

nimble stream
winged mortar
#

No

#

There's the line
doublepawnsquaremove.remove

#

Place that in the curly braces

nimble stream
#

its not supposed to be in there though

winged mortar
#

Becuase that's the line that's conditionally ran

nimble stream
#

oh

winged mortar
nimble stream
#

oh yeah it worked

winged mortar
#

This is why you should always add curly braces

nimble stream
#

my brain short circuted or smth lmao

#

ty

winged mortar
#

If you don't add them it'll just assume that the next valid statement is part of the if

#

You are welcome

livid hemlock
#

Hello, im trying to make enemy AI for my 2D bottom-up game and i cant figure out what is the best way to make an enemy dont fall from platforms and to lava, ive tried using A* pathfinding and NavMeshPlus (2D navmesh) but it is working only for 2d topdown

prime sinew
#

How about trigger colliders at the edge of each platform?

#

If overlapped, change direction

livid hemlock
#

thank you, i will try that

swift falcon
#

What is interpolate?
I am not really good at programming in unity so I don't even know what that is

#

Oh I searched on google

lean sail
swift falcon
#

Well thank you for your help, you probably just fixed an issue that I had for months

opaque lodge
#

is there a way to change exit time of a specific transition in runtime

#

by in runtime i meant in code

nocturne bronze
#

Hello im making a game where the player is falling but im runnign into the issue where while the player is falling if they press the left/right movement key they fall slower i have a feeling its got something to do with my extremely simplified movement controller

public Rigidbody2D myRigidBody;
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKey(KeyCode.A) == true )
            myRigidBody.velocity = Vector2.left * 5;

        if (Input.GetKey(KeyCode.D) == true)
            myRigidBody.velocity = Vector2.right * 5;

        myRigidBody.constraints = RigidbodyConstraints2D.FreezeRotation;
    }

is there any way to make it so that the player doesn't slow down
also im still a begginer and thats why my code is as simple as it is

lean sail
#

You should add to the velocity instead of directly setting it, and also limit the max speed for sure

lean sail
nocturne bronze
lean sail
#

Otherwise try experimenting with what I suggested. Just note it's really going to be harder if you're trying to learn c# and unity by yourself through trial and error

nocturne bronze
nocturne bronze
lean sail
lean sail
#

I would suggest just using add force, and also doing it in fixed update because that is where u want to do your physics stuff

nocturne bronze
nocturne bronze
supple oak
#

Velocity is a vector, containing both sideways movement (x) and fall speed (y). If you set the whole thing to a sideways direction, you're zeroing the fall speed. Instead, make a copy of the velocity, modify the x only, and then set the rigidbody velocity to the modified vector2.

fluid vector
#

can anyone vouch for a stable websocket client library? seems like every one i find is either abandoned, only works on net core or has hundreds of open years-old issues :\

#

or i guess if this is XY problem if anyone knows a better way of realtime communication between unity c# and a local node.js app

opal cargo
#

Hi guys, maybe someone can tell me what I'm getting wrong in jump physics based on the GDC talk of Kyle => https://youtu.be/hG9SzQxaCm8?t=559
I made an animation curve to layout the height of a jump over time (easy parabula 0->1->0 with peak at x=0.5) and wanted to read the velocity and gravity from it to have a nice, predictable and easy to configure jump physic. But at the moment my character only stays in place and flies through the air after hitting the end of the graph.

float velocity = (2*ctx.jumpAcc.Evaluate(TimeInState)) / Mathf.Clamp(TimeInState,0,1);
float gravity = (-2*ctx.jumpAcc.Evaluate(TimeInState)) / (Mathf.Clamp(TimeInState,0,1) * Mathf.Clamp(TimeInState,0,1));
jumpDirection.y += velocity;
jumpDirection.y += gravity;
GDC

In this 2016 GDC talk, Minor Key Games' Kyle Pittman shows how to construct natural-feeling jump trajectories from designer-friendly input like desired height and distance, modeled programmatically using one of a few available integration methods.

GDC talks cover a range of developmental topics including game design, programming, audio, visual ...

โ–ถ Play video
#

Math shows very high gravity at the start (around -200) and then decreasing, shouldn't it be the other way around?

iron pecan
thin aurora
# iron pecan

When calling a method, you don't need to specify the type

iron pecan
#

then how should i do it ?

iron pecan
iron pecan
thin aurora
#

You don't pass the type, just the variable name

#

If this is confusing for you then I highly suggest you get used to c# as a base first. This should not be a problem when you start using Unity, and these channels are not for it

iron pecan
#

then i should just need to specify master in it right ?

thin aurora
iron pecan
#

i did already

thin aurora
#

Then we fixed it

iron pecan
#

except no

thin aurora
#

You know these images don't help, we need more information

#

A stacktrace, error message, something like that

iron pecan
#

idk if you know french

sick stone
#

||waiting for my turn to ask a question...||

iron pecan
#

The name 'identifier' does not exist in the current context

knotty sun
iron pecan
#

but somehow it wasn't a problem when declaring parameters for the method in itself ?

celest ether
#

Hi! Could someone please help my with my stupid code? ๐Ÿ˜„ I am so stuck on this fading thing and I just can't seem to make it happen.

knotty sun
#

parameters are not variables

thin aurora
steep bison
thin aurora
knotty sun
iron pecan
sick stone
unborn oracle
#

hello guys i made a simple code for running but i want to shake the camera when player is moving how can i make it ? (running shake is the code for camera shake)

iron pecan
#

forget it, i'll ask chat gpt

autumn sphinx
iron pecan
#

good teacher

thin aurora
#

ChatGPT is not a way to learn programming

#

It is easy for AI to make mistakes, and there have been plenty of cases where people with 0 experience come here because ChatGPT gave them code that doesn't work

iron pecan
#

neither are unclear outdated wikis

#

best teacher is another person

#

but somehow they always bounce you for trying to learn

thin aurora
#

I assume you're talking about me suggesting that you learn c# first?

#

Do it for your own sake. There's no point in helping you with this issue in the first place, because you will just be stuck with the next step you take

iron pecan
#

i'm talking about absolutly anyone when you ask for help, so many forums start by sigh have you even looked it up ๐Ÿ™„

autumn sphinx
#

Is there a recommended resource for getting a feel for codestyle/organization best practices in unity scripts? I'm an experienced backend dev, just now getting into Unity and C#. I'm following a udemy course: https://www.udemy.com/course/unity-game-development-create-2d-and-3d-games-with-c

I'm on the first game and would like to get my habits in place early. His functions are loaded with nested if/else blocks. Is this a pretty common pattern just to avoid unnecessary computational overhead, or is breaking the code into tighter functions and objects not a huge issue for games that aren't pushing performance boundaries? Does the C# compiler inline short functions anyway?

thin aurora
iron pecan
#

when the forum in itself is first result to of the search, it becomes clear many people are confused as well, and when they look for the answers like the person initiating the thread, they are met with bitterness and sufficience, which is a plague that reaches anyone with a little experience it seems

autumn sphinx
iron pecan
#

it's extremely minimal, i am brand new, i started ayear ago, but seriously got to it like, 2 or 3 weeks ago, took me a while to figure out il hooks, but finally got it because i found a pearl of a coder that was willing to give helpful advices from time to time

thin aurora
autumn sphinx
thin aurora
#

But when I tell you that this is not the place for your question, it's not because I think you should Google it. I'm saying this because your question shows that you are indeed a beginner, and there are a lot of resources that will provide an infinitely better answer than I, or anybody else, ever will. I'm also saying it because I can't give you an answer in good faith, as you will most likely get stuck within seconds of fixing this. You should really get used to c# first before you start with unity

autumn sphinx
marble spindle
#

why python first tho

autumn sphinx
#

Once you've been coding for a while you forget just how hard it was to do things like wrap your head around a for loop. Removing as much overhead as possible allows for more wrestling with computational thinking and less wrestling with syntax.

swift falcon
swift falcon
#

hey anyone here can help me with this issue,so basicly i made a player and had in his script the rb.AddForce command and i stated that if u get input R button down it will do that command and it basicly works with other rigibodies but no the player,it only works when i remove the character controller from the player

#

btw rb is the name of the player

latent latch
#

Unity's character controller?

#

A CharacterController is not affected by forces and will only move when you call the Move function. It will then carry out the movement but be constrained by collisions.```
swift falcon
#

Which of these are better/faster?
I need to only get everything after the '/'

string binding = "<Gamepad>/buttonSouth"

        binding = binding.Split('/')[1];
        // or
        binding = binding.Remove(0, binding.IndexOf('/'));

// Output = "buttonSouth"```
wide fiber
#

This is script A basically acts like a input manager

public class P_Input : MonoBehaviour
{
    Vector3 moveInput;
    public float xAxis, zAxis;
    public float rotateInput;
    private void Update()
    {
        HandleInput();
    }
    void HandleInput()
    {
        xAxis = moveInput.x;
        zAxis = moveInput.z;
    }
    private void OnMove(InputValue value) => moveInput = value.Get<Vector3>();

    public void OnRotate(InputAction.CallbackContext context)
    {
        rotateInput = context.ReadValue<float>();
    }
}```

This is Script B, its for my player. This is where it executes movement and stuff that it gets from Script A
```cs
public class P_Movement : MonoBehaviour
{
    Rigidbody rb;

    P_Input p_input;


    [SerializeField] float speed;
    [SerializeField] float RotSpeed;
    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
        p_input = GetComponent<P_Input>();
    }

    void FixedUpdate()
    {
        Moving();
        Rotating();
    }

    void Moving()
    {
        Vector3 movement = p_input.xAxis * transform.right + p_input.zAxis * transform.forward;
        movement *= speed;
        movement += new Vector3(0, rb.velocity.y, 0);
        rb.velocity = movement;
    }

    void Rotating()
    {
        float rotation = p_input.rotateInput * RotSpeed * Time.fixedDeltaTime;
        transform.Rotate(0f, rotation, 0f);
    }

}```

I'm trying to get it to rotate but it didnt work, it didnt rotate. THere's no error or anything. I press the Button but it didnt budge. Anyone know why? ๐Ÿ˜ฆ
swift falcon
rigid island
swift falcon
#

you need to do player.Move(-transform.forward * -5);

#

it does like add forcec

#

but it is more of a teleport

#

like an actual dash

swift falcon
rain minnow
lethal plank
#

idk how to google it tho

uneven monolith
#

!code (just for i wanted link fast lol)

tawny elkBOT
#
Posting code

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

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

lethal plank
uneven monolith
#

no lol

#

i wanted link for myself to pastebin

#

:D

#

but realized i can do it without

lethal plank
#

alright

uneven monolith
#

So to my own actual prohlem

//what i have(simplified)

abstract class MyClass<T> : MonoBehaviour where T : MyClass<T>
{
    T Object;
    public abstract void Init();

    public T CreateInstance()
    {
        var data = Instantiate<T>(Object);
        data.Init();
        return data;
    }
}

//what i want,
abstract class MyClass<T> : MonoBehaviour where T : MyClass<T>
{
    T Object;
    public abstract void Init(TYPEPARAM _params);

    public T CreateInstance(TYPEPARAM _params)
    {
        var data = Instantiate<T>(Object);
        data.Init(_params);
        return data;
    }
}

SO, im trying to do this kind of inheritance base script that kinda works like this ||its more complicated, and im pretty sure it is what i want in this project, so no need to judge design thx|| but idk how i could have Init/createinstance have variable amount/type of parameters, like if it was constant amount i could just use generics but it isnt,...

one solution i can think of is make the init/createinstance take one generic parameter and use it as tuple elsewhere but if there are better solutions, it would be nice because tuples can be ewwwh

scarlet viper
#
int removed = cells.RemoveAll(cell => Physics.OverlapSphere(cell.position, 0.1f).Length > 0);

how can i remove cells only if the collider belongs to a certain object ?

#

overlapsphere returns a collider array but inside RemoveAll i cant seem to use it

uneven monolith
#

what type is cells@scarlet viper

#

i can test myself

dusk apex
#
fun(arr)
{
    foreach(...)
        if(...)
            return true;
    return false 
}```
uneven monolith
swift comet
#

Why is object bad?

rigid island
swift comet
#

Sorry, i meant as a reply to @uneven monolith

rigid island
#

nvm

#

yea lol

uneven monolith
# swift comet Why is object bad?

because then when i inherit i have array of 'object' types i just have to loop throught and set them to variables, it works, but when calling that inherited init (or createinstance) elsewhere, i have no idea which positions of objectarray are gonna be which parameters so its terrible readibility

swift comet
#

Yes you're right but thats the trade off.

#

Cant think of another way without trading off on readability.

#

You could use a dictionary/hashtable in a similar way

#

then atleast you would have the key to fall back onto

#

Init(Hashtable<string, object>)

uneven monolith
#

yeah, that could work

#

comes with own problems (strings lol) but has much more readibility

#

ill experiment a bit

#

one more solution im thinking is doing new struct for every Init and use that but idk if that is bit overkill and waste of time

swift comet
#

Ye thats another way

#

Why do you need something like that in the first place (just curious)

uneven monolith
#

its actually not for monobehaviours, but for scriptableobjects(i just thought that its not very relvant for question, and ppl are more familiar with MB), so i can quickly create different scriptable objects i can create and Init on runtime, and have this Init as their 'constructor', basicly i can turn any class to scriptableobject by changing the constructor name to Init and have them inherit this

#

idk if its actually optimal way of coding, or overkill, but i like overkilling stuff too much(i get wierd enjoyement out of it)

stark sinew
rotund burrow
#

i need to project one vector onto another but only on one side. so if the angle between 2 is more than 90 i need to get (0,0,0) as a result. right now i'm just doing an angle check but i'm looking for a better way.

fresh cosmos
#

if i have a scene loaded in with async and allowSceneActivation = false, how can i cancel its loading so it doesnt become active and stops being loaded in memory?

gray mural
#

Sorry for late reply, I have replied as soon as I have tested it.
Thank you very much for your help, time and full script that you have written, I really appreciate it!
I haven't changed anything in hierarchy and applied the script you have sent, but I do think that the same issue with multiple textComponents being added as before happens.
I also believe that that's kinda bad issue of TMPro namespace, so I wonder if I should consider redacting it or doing smth there.

eager yacht
#

Strange, never hit that. Might alleviate the empties by checking if the sliced string is string.IsNullOrEmpty and what not. Outside of that, the script should let you have a more straightforward debugging process at least.

gray mural
slate fern
#

why am I seeing 2 Colliders off any mesh? I am using 2 cameras and if I disable the second cam it works and im only seeing one collider. Using URP also

slate fern
vestal geode
slate fern
trim schooner
#

this is a code chan, you doing anything with gizmos in code?

slate fern
trim schooner
slate fern
vague slate
#

Any idea what AudioSource.pitch is exactly?
How much 1f is in tones?

#

What I need is to calculate how much given pitch value affects clip length

muted schooner
#

Is there a way to compare a loaded AssetBundle to the local assetbundle file?

#

Unity knows when an assetbundle has already been loaded, so I'm sure its possible, but there's no exposed method in the documentation that I can find.

late lion
vague slate
#

oh

cunning pivot
#
        slideDown = Physics.Raycast(transform.position, Vector3.down, out _slideHit, _slopeDetectionDistance, _slopeSlideLayer);
                Vector3 slopeDirection = Vector3.Cross(-_slideHit.normal, Vector3.right);
                Quaternion dir = Quaternion.LookRotation(slopeDirection);
                Quaternion slopeRotationY = Quaternion.Euler(0, dir.eulerAngles.y, 0);
                transform.rotation = slopeRotationY;

So i was trying to make the player face opposite of the slope he's sliding on and this works nice but since it uses Vector.right its in world space and not local space so if the slope is in another direction the result changes how can i fix that any help is appreciated thank you

#

its rotating towards the Z axis always

vague slate
#

this is a default slider

vague slate
#

huh??

spark flower
#

hello

#
        timerScore = timerScoreSet;

        pointsAC.keys[0].value = pointsShow;
        pointsAC.keys[pointsAC.keys.Length - 1].value = points;
        powerAC.keys[0].value = powerShow;
        powerAC.keys[powerAC.keys.Length - 1].value = power;
    }```
im trying to set some keys through code but it doesnt seem to work
leaden ice
#

define "doesn't work"

#

and explain what these datatypes are

#

because nobody can tell just from this context-free code

leaden ice
spark flower
#

bothAC are animation curves

#

im trying to set theyr keys through code

#

but in the inspector they seem to be betwean 0 and 1

#

not changed

leaden ice
#

if you want to modify the keys you have to copy the array out, make your changes, then copy back in

#

as the docs say

spark flower
#

ok

#

works like a charm

wintry crescent
#

Hi, I'm creating a struct, and I've never been more disappointed in my life

#

is there a workaround to this? I really need the default values for some of the variables

#

nevermind I can just use a class I guess

somber nacelle
#

You cannot use field initializers in a struct before c# 10
Use a parameterized constructor or a static factory method to create the instance with your preferred values if you want to have some default values for variables on a struct

#

Also keep in mind that Vector3.zero is already the default value for a vector3

wintry crescent
wintry crescent
late lion
# vague slate huh??

Pitch is basically a speed multiplier, which happens to change the pitch too, because that's what happens when you change the speed of a recording without any pitch correction. Negative speed means it plays backwards.

vague slate
#

(also very annoying it's not semitones)

jaunty needle
#

Hey guys, quick question, how do I make a piece of code run while I'm in edit mode. I want some objects to change their colour to red to easily show they're different

uncut tundra
#

Hi, Im trying to set a variable, as soo as i type those two lines in update, unity and visual studio start saying that the brackets need to be closed, how do i fix this???

muted schooner
#

remove the public modifier from the 2 variables you declared

uncut tundra
#

ok

#

thanks, that worked

shell scarab
#

what's the difference between

where T : notnull
```and```cs
where T : struct
```?
somber nacelle
#

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/constraints-on-type-parameters

where T : notnull The type argument must be a non-nullable type. The argument can be a non-nullable reference type or a non-nullable value type.
structs can be made nullable so int? would be valid for the second one but not the first
hmmm seems struct also specifies non-nullable value type ๐Ÿค”

somber nacelle
shell scarab
#

IK thought reference types can't be not null

somber nacelle
#

if you have nullable reference types enabled in the project then you could use them for that. it's not super useful for unity though

#

here's an example: https://dotnetfiddle.net/dmFBtD
you'll notice that line 8 is perfectly valid but line 9 shows a warning that the type string? is not a valid generic type parameter for the Test<T> class

shell scarab
#

ah

upper fjord
#

good evening i made this code which allows to visualize the object which i want to build by pressing on E but when i press on it i see well the object which moves with the values but i don't see it
https://hatebin.com/sygdiptjrj

digital coyote
#

Hello there, I am try to implement leaning into my fps game it already works, but when the player stops leaning the cam instantly snaps back instant of lerping back. can some on help pls.

somber nacelle
#

!code

tawny elkBOT
#
Posting code

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

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

somber nacelle
weary glade
#

I need help with 2D Pathfinding, I have A* set up and working. In my game I have these enemies that spawn when a player enters a room, then the enemies target the player instantly, this works fine, but i have huge lagspikes when the enemies with A* are spawned. Anyone know any possible fixes?

#

The lagspike is also only right when the enemie is spawned

somber nacelle
#

use the profiler to determine where performance issues are coming from

rain minnow
weary glade
rain minnow
#

The profiler should nail down what scripts and methods are creating the problem . . .

weary glade
#

the profiler said: playerloop

leaden ice
rain minnow
#

Sorry, forgot. Always use deep profiling โ€” it's invasive as fuck . . .

slow shale
#
```how do i clamp properly?(i cant clamp negative, in other words rot limitMin = -50, rotationLimitMax = 50, but when i try it in game it only works from 50-0, if it gets lower than 0 it snaps back to 50), like is there any simple way of doing it?
leaden ice
#

it's unclear what you are doing with this variable

slow shale
#
        float newRotationY = gunnerPivot.transform.localEulerAngles.x + Input.GetAxis("Mouse Y") * 100 * Time.deltaTime;

        newRotationY = Mathf.Clamp(newRotationY, rotationLimitMin, rotationLimitMax);
        gunnerPivot.transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f);```
leaden ice
#

wait maybe not?

leaden ice
#

you should be clamping the x rotation

slow shale
#

i am clamping the x rotation

gaunt blade
#

Yes I know it's not in snippet form, it's because I wanted to highlight things with a box and you cannot do that in a code snippet.

I'm confused why the compiler is determining the data type of "map[key] to be a "Geometry.Triangle" object when it's clearly defined as being a List<Triangle> object. Anyone know why this is happening?

slow shale
leaden ice
leaden ice
#

that's not going to work properly

#

you might get -15 or you might get 345

#

they're equivalent

slow shale
#

so how do i fix it?

leaden ice
#

you need to drive the rotation with your own variable instead of teading it from the transform

gaunt blade
#

I did use var, and when I attempt to treat the object like a List, it treats it like a Triangle object

slow shale
#

uhm, can you maybe explain in a more noobish way :))

gaunt blade
#

For some reason it's identifying the object as the wrong data type

#

I don't understand why

simple egret
#

Hover over map, what data type does it highlight?

leaden ice
# slow shale uhm, can you maybe explain in a more noobish way :))

something like this

float pitch = 0;
float yaw = 0;

void Update() {
    yaw -= Input.GetAxis("Mouse X");
    pitch += Input.GetAxis("Mouse Y");

    pitch = Mathf.Clamp(pitch, rotationLimitMin, rotationLimitMax);
    gunnerPivot.transform.localEulerAngles = new Vector3(pitch, yaw, 0f);
}```
gaunt blade
#

It's very clearly defined in the class field as being a List<triangle> object

leaden ice
#

Also @slow shale you should NOT have deltaTime in there

#

it's incorrect

slow shale
#

whats wrong with deltatime?

leaden ice
somber nacelle
simple egret
gaunt blade
#

Still a List<Triangle> object

simple egret
# gaunt blade

But yeah, you're indexing the dictionary, which gives you a list, then foreach iterates over the list, giving you a Triangle

slow shale
gaunt blade
#

Ooh, I see what you mean.

#

Wait

#

no I don't

somber nacelle
gaunt blade
#

I'm confused. The first foreach loops over the keys in the Dictionary, and "key" is the individual key.

The second loops over each key-value pair in the Dictionary, and the value should be a List object

#

So it should return a List

gaunt blade
somber nacelle
# gaunt blade

right. so what do you get when you foreach a List<Triangle>

simple egret
#

That double foreach is not really efficient btw, you can only use one on the Dictionary itself, which will yield some KeyValuePair<TKey, TValue>, that you can use .Key and .Value on

leaden ice
#

it's making your life hell

#

because you don't even know what type your variable is

gaunt blade
#

I don't use var, I only added it to prove a point to someone who said to add it

#

You can see I never use it

leaden ice
#

var gets rid of the compile error at the expense of you being confused

#

becuase Triangle is what should go there

gaunt blade
#

So I should be doing "in map" instead of "in map[key]"

leaden ice
#

what are you trying to do

eager yacht
#
foreach ((Vector2 key, List<Triangle> value) in map) {
  foreach (Triangle tri in value) { 

  }
}

sips

leaden ice
#
map = CreateMap(triangles);
foreach (Vector2 key in map.Keys) {
  List<Triangle> triangles = map[key];
  foreach (Triangle t in triangles) {
    // do stuff
  }
}```
Is this more clear @gaunt blade ?
gaunt blade
#

The hashmap is for generating a barycentric dual mesh. The Dictionary contains every point on the grid, and the value is the Triangles that contain that point as a vertice.

gaunt blade
leaden ice
#

just like how I showed?

#

notice the triangles variable is a List<Triangle>

#

that's the list you want, yes?

dusk apex
gaunt blade
#

Ah I see what you mean now

hexed oak
#

will a serialized C# dictionary deserialize into a std::map?

leaden ice
#

if the serialization format and CPP library for deserialization are compatible, sure

plain moon
#

How to make that effect. It's all 3D objects around even dashboard with shifter and steering wheel

#

How he's highlight it

echo plaza
#

Hey there, I was wondering how I could set the .WithControlsExcluding() from outside the code, since I have to different places to set keybinds, one for a keyboard and mouse, and the other for a controller. I can't do an if statement or a foreach loop so I was wondering if anyone had any idea what else I could try. Here is a snippet of the code, where if I try doing the if statement or foreach loop I get the error "Does not exist in the current context".

            // Configure the rebind.
            m_RebindOperation = action.PerformInteractiveRebinding(bindingIndex)
                .WithControlsExcluding("<Keyboard>")
                .WithControlsExcluding("<Mouse>")
                .WithControlsExcluding("<Gamepad>")
                .OnCancel(
                    operation =>
                    {
                        action.Enable();
                        m_RebindStopEvent?.Invoke(this, operation);
                        m_RebindOverlay?.SetActive(false);
                        UpdateBindingDisplay();
                        CleanUp();
                    })
upper fjord
#

why is it that when I import my model it's not the right way round?

leaden ice
leaden ice
lean sail
upper fjord
#

sorry

river kelp
#

Hey, I had some issues that forced me to upgrade to 2022 LTS from 2021 LTS. As expected this is a bit bumpy, but I have encountered something I can't really find a reason for. In the editor, I get the error "The name "Handles" does not exist in the current context" upon booting the game, although it appears to run just fine.

#

Intellisense finds Handles just fine

somber nacelle
#

you missed something on line 69

river kelp
#

Line... 69?

somber nacelle
#

oh sorry, since you didn't provide any actual information i assumed you just wanted us to make random guesses

simple egret
#

default(int) // 69

river kelp
#

I thought I provided the actual info..
Here is an example of a line using "Handles"
Handles.DrawWireArc(source.transform.position, Vector3.forward, startVector, aimBallAngle, 19, 5);

#

it's in "OnDrawGizmosSelected"

#

Visual studio finds handles just fine, and it compiles and runs, but I get this:

thick terrace
#

handles is an editor class while the other gizmos drawing stuff isn't so you might need to put an #if UNITY_EDITOR around that line?

river kelp
#

I know handles are a special class, like they are an editor only class right?

#

that would make sense but I'm in editor..

swift falcon
#

I am getting ~30 second compile times despite it being a relatively new project, my last project was a full massive game and only has compile times of ~18 secs
I'm worried it's because of the "Singleton" class I made for loads of managers:

public class Singleton : MonoBehaviour
{
    public static Dictionary<System.Type, Singleton> Instances = new Dictionary<System.Type, Singleton>();

    protected virtual void Awake()
    {
        if (!Instances.ContainsKey(GetType()))
        {
            Instances.Add(GetType(), this);
            return;
        }

        if (Instances[GetType()] == null)
        {
            Instances[GetType()] = this;
            return;
        }

        enabled = false;
    }

    public static T Get<T>()
        where T : Singleton
    {
        if (!Instances.ContainsKey(typeof(T)))
            return null;

        if (Instances[typeof(T)] == null && Application.isEditor)
            throw new System.NullReferenceException("Singleton Get returning null!");

        if (Instances[typeof(T)] is T instance)
            return instance;

        throw new System.Exception("Instances contains mismatched key-value pair: " + typeof(T).Name + " " + Instances[typeof(T)].name);
    }
}```

Have I made a horrible mistake? 
Get() has 63 references alone
There are probably close to 30 classes inheriting from Singleton
river kelp
#

and, this wasn't an issue prior to upgrading to 2022 LTS

somber nacelle
tawny elkBOT
#
Posting code

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

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

leaden ice
river kelp
swift falcon
swift falcon
#

Compile time, making a change to a script and then entering the editor

swift falcon
#

No do you think that would help?

swift comet
#

Ofcourse

swift falcon
#

If I change the value in the project settings will it automatically update all my scripts?

somber nacelle
swift comet
#

May not make much difference if there isnt much code Oops ye my bad, namespaces dont matter.

river kelp
#

Apparently I can just #if UNITY_EDITOR the whole section and it works, although the code does get called from the editor

swift falcon
leaden ice
river kelp
#

maybe 2022 contains an assert-y thing to confirm no code editor-only code is in a state where it would mess up a publish

leaden ice
#

if you're doing a build, then it will of course fail

#

Handles has never been accessible in a build

river kelp
#

I'm not doing a build, just running editor

#

pressing play, etc

heady iris
#

yeah, you should peek at the symbols that are defined

leaden ice
river kelp
#

The code is built, it runs, I can get break points to hit handles and it works

#

the handles stuff is drawn to the screen..

#

So that means it must be some kind of safeguard, right?

#

Maybe Unity got tired of the 250 questions they got every day about the same thing

swift falcon
#

I've seen a few mentions of disabling "Reload Domain"
This is disabled right? This was the default for me

river kelp
#

and if editor fixed the issue so.. maybe I'll just be more careful

heady iris
#

Reload Domain and Reload Scene are both going to happen.

somber nacelle
heady iris
#

Notably, I've experienced crashes with the Input System with domain reloading disabled after updating an input action map

#

specifically, when trying to get display strings for bindings

river kelp
#

appears to be my default settings

ashen yoke
swift falcon
#

Didn't seem to make any difference anyway, still about 30 secs

ashen yoke
#

and it will disable both reloads

swift comet
#

Get more RAM or better CPU ๐Ÿ˜… SSD would help a lot.

soft shard
ashen yoke
#

@swift falcon tho i advice to keep scene reload enabled

swift falcon
#

My previous project was waaaaaay bigger than this one and is ~18 secs compared to ~30 secs

ashen yoke
#

so did you do it? its works?

swift falcon
#

Yeah I did what you said there, took about 3-4 secs off but nothing major

ashen yoke
#

then its not domain reload that eats up time

#

do in empty scene

swift falcon
#

While the new project is loading, I read somewhere that newer versions of Unity have faster compile times
I'm using v2020.3.25f1 right now
Is it worth it to upgrade?

ashen yoke
#

why new project

#

new scene

#

in the same project

#

the gains of "compile time" by unity are marginal

swift comet
#

Is your project on SSD? or HDD?

ashen yoke
#

compile time is very fast, if it was only compile time you would have 3 second compilation on massive projects

#

the issue is that after compile it does domain reload

#

and that take very long time and even with their changes it barely affects anything

swift falcon
#

New scene: 35 secs
New project: <5 secs

ashen yoke
#

new scene in the same project 35 seconds only to enter playmode?

#

and you are certain you have domain reload disabled?

#

empty scene with no domain reload should instantly enter play mode

swift falcon
#

Not to enter playmode. If I change a script, save and then re-enter Unity it takes 30-35 seconds before I regain control

ashen yoke
#

see whats written on that option?

swift comet
#

It really depends on PC specs too

swift falcon
#

That was with Play Mode Options disabled

ashen yoke
#

its says Play Mode

#

there is nothing about compilation there

#

you cant skip domain reload on compilation this option doesnt affect it in any way

heady iris
#

i'm not sure if there's a way to profile what's taking up time in the compile -> reload process

ashen yoke
#

domain reload what else

heady iris
#

well, yes

ashen yoke
#

and that is affected directly by drive/cpu/ram

heady iris
#

but the question is whether something is taking up an abnormal amount of time in that process

ashen yoke
#

if empty project takes 5 seconds id say its pc specs

#

i get 1-2 seconds on empty

#

@swift falcon disable that option back to default state

swift falcon
#

My previous project had over a year of development on it
This project has about 3 weeks

There's no way there's not something weird going on here

heady iris
#

time spent developing does not correspond to the amount of work that has to be done

#

if you think there is something that's taking an abnormal amount of time, you could search for it by creating a new project and then bringing script assets over to it

swift comet
#

Can always call this in editor code to see if your compilation takes long CompilationPipeline.RequestScriptCompilation();

swift falcon
#

Which seems a bit insane

swift comet
#

Is the project on SSD?

west path
#

how do i make mesh data (verts / triangle) in a unity job from a noise map

swift falcon
swift falcon
#

It's one of the only differences between the two projects

#

In my main assembly there are 51 scripts, 30-45 second compile time
In my previous project with no custom assemblies there are 203 scripts, 18 second compile time

#

hm, ok
I restarted the project, closed all other projects and suddenly the compile time is back down to a few seconds

So...problem solved I guess
Anyone know what could have been going on in the background there?

knotty sun
dusk apex
swift falcon
#

Everything outside my main assembly has no dependency on anything inside the assembly, if that's what you mean

Maybe leaving the project open for multiple days had something to do with it
I'm not gonna get too bothered about why it happened, at least it was a good learning experience

swift comet
#

multiple days kekwait

swift falcon
#

Is that not normal lol?

#

Whoops

swift comet
#

I almost said did you close the project recently

swift falcon
#

Well thanks everyone for the help anyway lmao

heady iris
#

singleton or otherwise

lean sail
# swift falcon Is that not normal lol?

I used to leave it on overnight, until one day my pc crashed while I was asleep and there was a major bug in my project (which I assume was due to unity not shutting down properly). So I'd advise closing it when done, performance reasons aside

ashen yoke
#

always commit your work when you finish working

#

at least stage it

heady iris
#

i'm bad about not committing partway through an implementation

#

i should just squash them before pushing

ashen yoke
#

just commit, no need to push

swift comet
#

I quite like perforce because of that, its all CLs no commits ๐Ÿ˜…

ashen yoke
#

in the morning you can push it in a new branch if needed

earnest gazelle
#

How do you implement fog of war in voxel games? The voxels should get visible if they are close to npc characters.
Add a boolean field for each voxel named IsVisible and consider a range?
Then the voxel shader uses isVisible voxel data to show/hide them?

heady iris
#

oof, that's a tricky one

#

making it performant, at least

ashen yoke
#

or projected from top masking

#

you can for example have a sphere on each npc that sets stencil value

#

then camera from top renders the scene using that stencil value into a texture which is used by voxel shader to drive color

earnest gazelle
ashen yoke
#

minecraft doesnt have fow

earnest gazelle
#

Yes, it can contain float voxels as well

heady iris
#

but with fog of war

ashen yoke
#

yes that i understand my question still stands

#

full 3d fow means you have full voxel volume to process, with problems like occlusion

earnest gazelle
heady iris
#

fun (tm)

earnest gazelle
#

It is full 3d voxel game with sparse voxels in different heights

ashen yoke
#

its going to be a nightmare

#

there probably is some whitepaper with efficient algorithm for that

#

something along bresenhams line but for 3d

earnest gazelle
#

Also, if a voxel gets visible, it will be visible forever

ashen yoke
#

still

earnest gazelle
#

Why nightmare?
My approach does not work?
Add a boolean field for each voxel named IsVisible and consider a range?
Then the voxel shader uses isVisible voxel data to show/hide them?

ashen yoke
#

well there is stencil based occlusion technique which is supposed to be very performant, maybe that can be applied somehow

#

but that requires camera

#

otherwise maybe raycast in a Job

#

do massive amounts of raycasts

earnest gazelle
#

You mean to hide/show items on voxels or just render voxels as black voxels or normal voxels?

ashen yoke
#

to flag voxels and not flag occluded voxels

#

rendering that should be relatively easy

#

you can use Texture3d

earnest gazelle
#

Yes, just set black color to hidden voxels is really easy but showing/hiding 3d items, enemies, npcs on those voxels are nightmare

ashen yoke
#

check stencil occlusion

earnest gazelle
ashen yoke
#

or easier

#

you can sample the nearest voxel

#

if the voxel is visible so is the object

earnest gazelle
#

To show/hide 3d elements (items, enemies, etc.) on voxels, I can check if they are on hidden voxels or not, then based on that, render them or not. I think it would be OK

ashen yoke
#

hivemind

#

tho stencil occlusion here would work just as well imo

#

since you have a special case where only thing writing into buffer is voxels

#

or rather the only thing occluding

earnest gazelle
#

:/ but it would not be ideal. Suppose an enemy moves from a hidden voxel to visible one.

ashen yoke
#

and what happens?

earnest gazelle
#

It renders completely after going to the visible voxel

ashen yoke
#

right, so you have to keep updating known voxel state on move

#

not only known flag, but also currently visible flag

#

is it realtime?

#

turnbased?

#

you can update on move and at custom tickrate

#

say 4 times a second

earnest gazelle
#

I mean the model (mesh) is completely visible or hidden not parts of it hidden and the other parts visible in voxel edges

ashen yoke
#

in a job, and on a separate voxel structure that only stores visibility flags

earnest gazelle
#

It is a city building game

#

OK, I test it. I think it is OK to render objects or hide them I mean the full body. Appreciated.

echo plaza
#

Hey there, I was wondering how I could change this script so that it only removes the custom keybinds for either a keyboard and mouse or a controller.

using System;
using UnityEngine;
using UnityEngine.InputSystem;

public class ResetAllBindings : MonoBehaviour
{
    [SerializeField]
    private InputActionAsset inputActions;

    [SerializeField]
    private Boolean gamepadRebind;

    public void ResetBindings()
    {
        foreach (InputActionMap map in inputActions.actionMaps)
        {
            map.RemoveAllBindingOverrides();
        }
        PlayerPrefs.DeleteKey("rebinds");
    }
}
rain minnow
bitter cape
#

Hello, I want to be able to check the RGBA values of the set of pixels from a 2D texture on a model that a collider is colliding with. How can I achieve this? I think I might have to use Texture2D.GetPixel() but I don't what x and y coordinates I should check based on the collision. If it helps, the collider is spherical

bitter cape
quartz folio
blissful crater
#

Hi!

bitter cape
#

My code is:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PaintDetector : MonoBehaviour
{
    private void Update()
    {
        RaycastHit hit;
        if (Physics.Raycast(transform.position, Vector3.down, out hit))
        {
            Paintable paintable = hit.collider.gameObject.GetComponent<Paintable>();
            if (paintable != null)
            {
                Texture2D tex = toTexture2D(paintable.getMask());
                Color color = tex.GetPixel((int)(hit.textureCoord.x * tex.width), (int)(hit.textureCoord.y * tex.height));
                Debug.Log(color);
            }
        }
    }

    Texture2D toTexture2D(RenderTexture rTex)
    {
        Texture2D tex = new Texture2D(512, 512, TextureFormat.RGB24, false);
        // ReadPixels looks at the active RenderTexture.
        RenderTexture.active = rTex;
        tex.ReadPixels(new Rect(0, 0, rTex.width, rTex.height), 0, 0);
        tex.Apply();
        return tex;
    }
}
quartz folio
#

Regardless of the offset, this is a memory leak, you are constantly creating new Texture2Ds, you need to call Object.Destroy on them when you are done with them, otherwise you're just accumulating them

bitter cape
quartz folio
#

Texture2D's are UnityEngine.Object types, which are mostly native objects

#

I'm not sure what your entire setup is, it could be doing that for all sorts of reasons, like offsets defined on your material or in your shader, which are not taken into account by hit.textureCoord

#

Also note that

Paintable paintable = hit.collider.gameObject.GetComponent<Paintable>();
if (paintable != null)

can just be

if (hit.collider.TryGetComponent(out Paintable paintable))
lime drift
#

Hi guys. Do you need any help with your sprite creation? I like helping.

tawny elkBOT
lime drift
#

thanks

bitter cape
molten sandal
#

Good day community, I am here to ask if some one has a good guide or documentation about wolrd and local space because I am struggling a lot with properly understanding how they work and how to transfomr from one to another

#

I have an object tree like this:
Player 1
|--- Vehicle
|--- Camera

I need a simple script attached to the camera that will target the vehicles and for now just a simple function that will keep the camera behicnd the vehicle minus a configurable offset

#
using UnityEngine;

public class VehicleCameraController : MonoBehaviour
{
    public Transform target;
    public Vector3 offset;

    private void LateUpdate()
    {
        transform.position = target.position - offset;
    }
}```
#

Like this

#

but those calculations are in world space

heady iris
#

local space is from the perspective of the object

#

if you want a position 10 meters behind an object, you need to get a vector that points backwards (from the object's point of view), then scale it and add it to the object's position

#

e.g. target.position - target.forward * 10;

#

Transform.forward is a world-space vector that points in the transform's forward direction

#

in local space, that vector is always Vector3.forward

#

because from your POV, forward never changes

#

it's just...forward

molten sandal
#

Ok, thanks, let me try

#

And a would like to ask for an advice

#

because most of the issues I am having are probably because I don't know if should I make the calculations in world space or local space or it depends of the case

heady iris
#

you must know which space you're working in

#

for any Transform, you can convert from world -> local and local -> world

heady iris
#

you could also do it in local space

#

target.TransformPoint(Vector3.back * 10)

#

Vector3.back is [0,0,-1]

#

we scale it to [0,0,-10]

#

then we use Transform.TransformPoint to convert it from local space to world space

#

Although, this would be wrong if the transform was scaled at all.

#

you can see this for yourself by parenting two cubes together, offsetting the child, and then scaling the parent

#

the child moves

heady iris
molten sandal
#

OK ok, I get it thanks

#

For the problem I have right now is that I need to make a camera controller that follows a high speed hovercraft over a track, such hovercraft can yaw, pitch, roll and turn basically to any direction, for this specific problem do you recommend doing all the calculations in world space or local space?

heady iris
#

well, I would recommend just using Cinemachine

molten sandal
#

hm...

heady iris
#

it's a great camera control package

molten sandal
#

I got it

#

I tried it

#

and I face a problem that I was not been able to solve

#

by any mean

#

When using a smooth transform like lerp or slerp that makes the camera to try to follow, the faster the object moves, it takes the camera longer to reach the object, so it starts to get left behind

heady iris
#

you don't have to move the cinemachine virtual camera yourself

#

you just use the Transposer mode

molten sandal
#

This is not very notorious for low velocity, but it is a problem for velocieites with a magnitude > 1000km/h

molten sandal
gaunt blade
#

Does anyone have some suggestions on how to optimize memory usage

#

I feel like just what's on the screen should not be taking up 6.6GB

#

With this type of memory usage there's no way I can do a map generation algorithm. This data needs to be much much smaller.

quartz folio
gaunt blade
#

For some reason there's a ton of reserved memory

#

Do you have any idea why it'd be reserving so much memory. I don't have 5GB of memory to just throw into unity for the sake of it

quartz folio
#

You likely allocated that amount of memory previously

#

Restart Unity and take a look at the size of the memory pool when you've only done the thing once

#

If you've not been destroying objects correctly then you've perhaps allocated a large amount, causing the memory pool to enlarge, but Unity managed to clean it up at some point when Resources.UnloadUnusedAssets was called automatically

gaunt blade
#

How am I suppose to destroy objects correctly?

#

Yeah it's a lot better after restarting the editor

#

But I'm confused what I'm doing wrong to have it keep reserving memory over and over.

quartz folio
#

whenever you new a UnityEngine.Object like Mesh it is up to you to call Object.Destroy on it when you are done with it

#

GameObject and Components in the scene are the exception

stark sinew
quartz folio
#

There are other things that allocate new objects, like calling render.material, and it's also up to you to destroy those materials too

gaunt blade
quartz folio
#

Yes, GameObject and Component are UnityEngine.Object, but they will be destroyed when the scene is, so you don't have to do anything about it

#

but assets like Materials, Meshes, RenderTextures... they will only get destroyed when you call Object.Destroy. They may also be destroyed if they are not referenced when a scene is loaded non-additively beacuse that calls Resources.UnloadUnusedAssets

gaunt blade
#

So in this case, should I be calling "color.Destroy()" at the end of the function

quartz folio
#

Color is a struct, it's not a UnityEngine.Object subtype

#

Also, new LineRenderer() is invalid code, AddComponent is already creating the LineRenderer

#

There are other easy ways to allocate loads of memory when dynamically creating meshes that are not memory leaks. Accessing mesh.vertices or similar properties will allocate an entire array of Vector3's every time it's called. A common mistake is to write code like:

Vector3[] vertices = mesh.vertices;
for (int i = 0; i < mesh.vertices.Length; i++)

which is incorrect because now it will allocate a whole new array on every iteration of the loop to check the length.

gaunt blade
#

So you want to create a container before the loop and repeatedly refernece that container so it's only generating a single one instead of generating new ones over and over

#

I might be doing that

#

Or does that only apply to meshes?

quartz folio
#

It only applies to mesh properties

#

Many properties on UnityEngine.Object subtypes will have similar behaviour though

gaunt blade
#

I must be doing something like that because my memory usage shot up from 2.2GB to almost 7GB the second I clicked play

#

Yeah it has to be something along those lines

bitter cape
#

Based on the hit.textureCoord that's getting logged, the RGBA value should NOT be all 0's here, yet it is

quartz folio
bitter cape
quartz folio
#

Though I can't see your complete setup or whether or not the texture is the same one you create here, just some code has changed. But it's those sorts of discrepancies that can cause your issue

bitter cape
#

I just changed it and now it works!

#

Thank you so much!!!

night harness
#

Not sure where the best place to ask this is but any suggestions on where to get assistance with DOTWeen Pro? Having a terrible time with it

prime sinew
#

Any of the code channels

night harness
#

I've been really struggling on how to actually use it, The documentation seems super lackluster. Currently I have some DOTweenAnimation's and I'm trying to run them via code and run a function on complete when it's done but I can only find examples of doing that with a specific tween function rather than a DOTweenAnimation

prime sinew
#

Have you found the documentation?

#

I'm afraid I don't know what a DoTweenAnimation is, so I can't help

night harness
#

Are you just meant to either exclusively use the inspector based DOTween Animations and chain via drag and drop or exclusively do it all in specific code based tweens, I've found very little on the combination of both

night harness
prime sinew
#

Best to also show the code

night harness
#

An example of what I want to do is something like

leftObjectiveUI.primaryLoadTween.OnComplete(() => ClearObjectiveUIData(ObjectiveUIPreference.Left));

or

leftObjectiveUI.primaryLoadTween.DOPlayBackwards().OnComplete(() => ClearObjectiveUIData(ObjectiveUIPreference.Left));
mossy valley
#

How to fix "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)"

mossy valley
oak tusk
#

Hey guys! I was seeing if anyone can help me with a movement script. The script I made doesnโ€™t let me move or look around

wide terrace
oak tusk
#

I probably sound stupid Iโ€™m sorry haha I just need help with a new script for my movements.

mossy valley
#

Yeah I could, thank you

wide terrace
tawny elkBOT
#
Posting code

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

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

wide terrace
cobalt gyro
#
        {
            string json = JsonUtility.ToJson(toSave);
            if (File.Exists(jsonFile + ".json"))
            {
                File.WriteAllText(jsonFile, json);

                File.Encrypt(Application.dataPath + jsonFile + ".json");
            }
            else if (!File.Exists(jsonFile + ".json"))
            {
                File.Create(Application.dataPath + jsonFile + ".json");
                File.WriteAllText(jsonFile, json);

                File.Encrypt(Application.dataPath + jsonFile + ".json");
            }
        }``` Does anyone know if theres a better way to do this
mossy valley
#

Ah right that worked

oak tusk
lean sail
#

i also dont think u want to use File.Encrypt.. i believe its only on windows but i could be wrong. This is just from memory

cobalt gyro
lean sail
#

though I would at least look at a high level overview of how encryption works, for whichever algorithm u choose. AES is popular

cobalt gyro
#

ight

#

thanks

lean sail
# cobalt gyro thanks

also just to note, this will pretty much only deter people from editing the written file. Local encryption is pretty much impossible to make secure

cobalt gyro
#

ik

oak tusk
prime sinew
#

Stick to one channel

ashen yoke
#

whats the easiest way to generate guid in vs?

#

c# interactive works

ashen yoke
#

interactive works

#

Print(Guid.NewGuid())

ashen yoke
#

are there any known popular libs that have TypeID attribute

#

i dont want to create name collisions in the future

#

doesnt matter ill rename if they happen

leaden solstice
#

Namespace it? UnityChanThink

ashen yoke
#

its going into one of the most commonly used namespaces project wide, so collisions on name are almost guaranteed

#

i trade availability for potential collision in the future

cosmic rain
jovial spindle
#

Hello, kinda wierd question but what you think would be better name for showing additional windows in UI:

  1. ToggleWindow(bool)
  2. ShowWindow(bool)
  3. TurnOnWindow(bool)
lean sail
#

the way u described it was so we could understand the context, the function name should do the same to someone reading it for the first time

jovial spindle
#

Yea I agree, just had trouble wrapping my head around but got to same conclusion. Thanks! ๐Ÿฆ†

ashen yoke
#

is there some non alloc version of GetCustomAttributes?

#

allocating an array for each type in the project is overkill, what is this api

primal wind
#

If I remember correctly you can just call it on the assembly itself

ashen yoke
#

it returns bare attributes or attributeData

#

both dont provide type they are bound to

#
public static Attribute GetCustomAttribute(Assembly element, Type attributeType, bool inherit)
{
     Attribute[] customAttributes = Attribute.GetCustomAttributes(element, attributeType, inherit);
spark flower
#

can i check just a dot for a collision and not an entire ray?

lean sail
spark flower
#

3d

lean sail
# spark flower 3d

you would be checking more if a point was inside a collider
Physics.OverlapSphere(some position, 0f) should work

spark flower
#

what do you mean

lean sail
delicate moon
#

Hello !

I'm sorry, I really need help !

So I have a project, I have a map rendered with a RenderTexture. I want to be able to click on a button, which is on this RenderTexture.
My RawImage displaying the RenderTexture is on a canvas with the mode Screen Space Camera, without any camera gived to the Camera field.
My Canvas displaying my Map is on a World Space Canvas, directly on the scene, with the camera displaying the render texture on top, as its parent.
I tried this :
https://gamedev.stackexchange.com/questions/198782/how-do-you-get-the-texture-coordinate-hit-by-the-mouse-on-a-ui-raw-image-in-unit

But the coordinates are wrong. (Not upside down, really wrong).

I tried this as well: https://forum.unity.com/threads/interaction-with-objects-displayed-on-render-texture.517175/
Changing eventCamera by the Camera displaying the renderTexture since I needed my canvas displaying my RenderTexture to be in WorldSpace for it to function, and I cannot do that in my project.

I tried a bunch of other stuff as well, but these were the ones where I had the best results so far (But both doesn't work...)

Anyone could help me please ?

Sorry for my mistakes, I'm not english ^^"
Thank you very much !

molten thicket
#

Hi guys,

I'm stuck with collision detection in 2D.

I have two game objects, A & B.

I want to trigger logic when A collides with B using onTriggerEnter2D - However when they collide, nothing happens?

Both have colliders and both colliders are set as triggers. Any help would be greatly appreciated ๐Ÿ™‚

latent latch
#

One needs a rigidbody, but you can set it as kinematic

molten thicket
#

So if one is a door and the other an enemy - Would the enemy have the Rigidbody? or does not matter?

(Thank you)

latent latch
#

Ah, if it were like a coin to pickup, I believe you want to make a collider on the character the trigger, and the coin the object with the kinematic rigidbody + non-trigger collider

molten thicket
#

That's useful - Did not know that. Will give it a spin ๐Ÿ™‚

urban estuary
#

Hmm would anybody be willing to lend a hand with a wierd issue im running into, basically I've run a BoxCast underneath a 2D player that toggles a bool on and off this works perfectly, However I also use this bool to set the parameters of my physics2d material and it changes the friction from 0.04 the default to 0.0 when in the air so the player can't stick to the wall however it doesn't seem to actually update any of it even though the material is definitely on the player is there a different method im supposed to use here?

#

to note I can physically see the changes happening inside the inspector and the physics material is on my 2dbox collider

latent latch
#

Create instances of the material and swap it out depending on the situation

#

https://forum.unity.com/threads/change-the-bounciness-of-physics-material-2d-randomly.660673/#post-4423300
bit more insight from this post. They behave similar like normal shader material where there's a persistent instance of it, so you'll always want to create a copy or use two different materials when you want different values.

#

Apparently attaching the phyics material directly to the rb, it updates all colliders to it which I didn't know

delicate moon
drifting crest
#

I want to load one object from first scene to another with all the refrences in it , currently I am using don'tdestroyOnload the object is getting loaded but the refrences in the inspector given from first scene are gettting delted how can I load them as well?

thin aurora
harsh ridge
#

oh mb

thin aurora
#

You probably get a quicker answer there

ruby fulcrum
#

why does transform.getcomponentsinchildren only get one instance when i have 15 instances, the objects are being made by pooling (instancing) 15 times in start from a prefab

delicate moon
ruby fulcrum
#

nvm fixed it

#

forgot to enable include inactive

bold flare
#

Good afternoon! cat_hi
Is there a way to destroy a gameobject or component (like a script attached to a gameobject), and make it not reappear? If not, which value (like a reference to the destroyed objects) can I store in my save file to destroy the objects again on game load?

Thanks! ๐Ÿ™๐Ÿฝ

latent latch
#

Which do you want to destroy, a gameobject or component

bold flare
#

No-

#

I want to destroy it, but keep it destroyed when the game launches back

latent latch
#

So, are you asking how to serialize a game object without specific components

bold flare
#

For exemple, let's say I have a "tutorial" gameobject. When the tutorial is finished, I want to destroy it, and I don't want it to appear back when the game will be started a second time.

scarlet viper
#
  EditorApplication.playModeStateChanged 

anything that executes after i click Play but before the game launches ?

#

This one executes after game launches

bold flare
heady iris
#

What you can do is immediately destroy the component upon loading the scene

#

or, perhaps, choose not to create the component at all

#

so rather than having to destroy a component in the scene, you simply choose not to create a component

bold flare
heady iris
#

I don't know what your use case is.

latent latch
#

You'll have to flag it for when you deserialize the data you'll know not to create the GO with that specific component

heady iris
#

ah, I didn't read it, whoops

#

๐Ÿซ 

#

I would suggest having a component that checks if this is the first time you've played

bold flare
#

So, instead of creating the gameobject in the editor, and destroying it after game load if necessary, I should instantiate it with a prefab on game load, if I want to?

heady iris
#

If so, it spawns stuff to run the tutorial

#

right. that way, you don't have to deal with the tutorial components' Awake methods running

swift comet
bold flare
#

(the tutorial was just an exemple, I won't check if it's the first time, but I understand correctly)
Thank you again, @latent latch and @heady iris. Your help is very appreciated!

latent latch
#

^^

bold flare
#

Uh-
Wait

#

Yeah, nvm, I just have to implement all the instantiating logic and conditions in my LoadingManager, I suppose. This seems a bit strange to me tho...

heady iris
#

no, you should just have a "tutorial spawner" component whose job is to check if the tutorial should be spawned

bold flare
#

So, for each script or gameobject I want to instantiate, I need to have another script on another gameobject that will do the spawn?

heady iris
#

Well, I would suggest just having one that handles everything.

#

It is the tutorial spawner. It spawns the tutorial.

#

Alternatively, you can leave the tutorial components and objects disabled, and then activate them if desired

bold flare
#

Mh... So, as we said, I should hard-code the conditions and logic to instantiate in a dedicated script. Alright, thanks again!

bold flare
#

I'm absolutely sorry to follow up this conversation... There is so much things to instantiate, I'm sure there is a better way to do it... I mean, it can be some "interactor" script on all chests, killed bosses, destroyed rocks, picked up items... Do you imagine the number of lines of code I'll have to write each time a "permanently destroyable" object will be added to the game???

heady iris
#

okay, so now you're asking about a whole save-game system

#

that is a significantly harder problem

wintry crescent
#

Hi, I have a script that I'm using in the editor, to spawn copies of a prefab as childobjects. This happens outside of playmode
The script is attached to a gameobject
But I have a problem now - when I use this script to spawn a lot of objects, and I click on one of them in the scene view, the object gets selected in the hierarchy - but the hierarchy has, say, 300 objects now. And If I want to see the main root object that spawned all those objects, I have to scroll a lot and find it. I would like to make it easier to select the root object - is there something that could help me?
I cannot put it in a prefab (which would work as I'd like it to), because you cannot destroy gameobjects in prefab mode, as of 2021.3.20 at least

#

I'm specifically after the behaviour that happens when you have a prefab with multiple childobjects, and you click on one of them in the scene view - the prefab gets selected in hierarchy, instead of the childobject

bold flare
tepid brook
#

Hi guys i want to move a gameobject in an other gameobject but i want to keep the position.
when i move the object in the hierarchy its work but when i do it in script its not work someone can help me pls ?

heady iris
#

see the worldPositionStays overload

tepid brook
#

i've try with true and false and its same

heady iris
#

the entire point of worldPositionStays is that the world position stays

bold flare
heady iris
#

[SerializeField] just tells unity to serialize a field on an Object that would not otherwise be serialized

#

e.g. a private field

tepid brook
#

my object position is 0,65,0 when i move it in the gameobject with the hierarchy its -225, -895, 0 but he keep his position on the screen.
but if i setParent in script position is -940, -1245, 0 with false and if i put it to true its 0,65,0 but in the 2 case the object position is not the same as i do with the hierarchy x)

heady iris
#

if you're looking at the Transform component in the inspector, that shows local position/rotation/scale

cunning pivot
#

@leaden ice Look who i just found on them Unity forums hahaha

leaden ice
cunning pivot
swift falcon
#
    private void Update()
    {
        TakeInput();
    }

    private void FixedUpdate()
    {      
        SetVelocity();
    }

    void SetVelocity()
    {
        rb.velocity = new Vector3(xInput, yInput, yInput);
    }

    void TakeInput()
    {
        xInput = Input.GetAxis("Horizontal") * speed * Time.fixedDeltaTime;
        yInput = Input.GetAxis("Vertical") * speed * Time.fixedDeltaTime;
    }

I dont think I ever used Velocity directly with input properly, is this good?

#

The speed looks consistent

heady iris
#

Sounds reasonable.

#

oh wait

#

why's fixedDeltaTime in there?

#

you're setting the velocity, not adding to the position

swift falcon
#

Yeah thats what i was looking it myself, should I just remove it and not use any times there?

heady iris
#

Your velocity should not depend on your framerate or the physics update rate

#

so, yes

swift falcon
#

alright

#

I just thought the input value would change quicker based on the framerate, but i dont know

heady iris
#

it's going to be a number between -1 and 1

swift falcon
heady iris
#

that would be irrelevant

#

you just want the value

#

multiplying it by a constant wouldn't change how quickly the input changes

#

it'd just rescale the input

swift falcon
#

oh yeah

heady iris
#

if you want to make your velocity change non-instantaneously, then you'd need to do something in SetVelocity

swift falcon
#

Ive used GetAxis all the time but I still ask such goofy questions lol

heady iris
#

deltaTime doesn't cause stuff to change smoothly over time

#

it just converts "X per frame" into "X per second"

bold flare
heady iris
#

you need a way to uniquely identify each game object

#

I'm not sure what the best way to do that in general is, sinec I haven't implemented that myself

#

I have done saving and loading based on ScriptableObject assets (e.g. I have an SO asset for each bonfire in my soulslike game)

#

in that case, I copied the asset GUID into the ScriptableObject

#

giving me a nice unique ID

barren meadow
#

i have a question

public bool BirdIsAlive = true;

this is in one script called LogicScript, and in another script called BirdScript there is a function that requires this variable

    if (Input.GetKeyDown(KeyCode.Space) && BirdIsAlive)
    {
        MyRigidbody.velocity = Vector2.up * FlapStrength;
    };

question is: how do i get the value of BirdIsAlive from LogicScript to BirdScript?

thin aurora
#

Do they have something in common like a manager that spawns them?

#

Are there multiple logicscript scripts?

#

Do they exist in the editor or instantiated later?

floral fractal
#

is there any methods from System.IO or AssetDatabase or Resources basically whatever, that can get the amount of file on spesific folder, Like
Resources.LoadAll or AssetDatabase.LoadAllAssetAtPath are returning array of something, and i can do arr.Length to get how many item present, but i dont want to load that, i just want to know how many item there, thanks

dim whale
#

That said, System.IO will find all files, including meta files.
AssetDatabase filters objects related to the project

#

There is also AssetDatabase.FindAssets() that uses the same search filter as in the Editor Project View

#

and can search in specific folders

barren meadow
thin aurora
tepid brook
#

Can someone help me to change the parent of an object and keep its position like in the hierarchy ?

heady iris
#

the local position, rotation, and scale will change when you call SetParent with worldPositionStays=true

tepid brook
heady iris
#

that is expected

#

If you're parenting it to a non-uniformly-scaled parent, then that could cause distortions

tepid brook
#

my problem is the position not the scale

#

when i drag my gameobject to the parent in the hierarchy its work

heady iris
#

perhaps you can show what's happening

tepid brook
#

sure

floral fractal
tepid brook
#

So i create a line beetween 2 circle in the left side this is my gameobject position when it spawn, and on the right this is the position when i move in Hierarchy.
its perfect that what i want but i need to do that witch a script and when i do it in script the position is not the same and my line is out of screen do you underrstand what i want to do ?

heady iris
#

seems like a z-fighting issue

tepid brook
#

so what i need to do ?

#

And when i setParent in script this is the position of the gameobject (out of screen)

#

i don't know how the position is calculated when we move the gameobject in hierarchy but i want the same in script x)

heady iris
#

oh, these are UI elements

#

with rect transforms

#

are you sure you're getting an identical hierarchy layout

tepid brook
heady iris
#

this is a UI

#

Children render in front of parents

#

and later siblings render in front of earlier siblings

#

Look at how the three objects -- the two circles and the dashed line -- are positioned in the hierarchy

tepid brook
#

this is my hierarchy and the line spawn on RoomMap and setParent to MapImage

heady iris
#

and is that exactly how it looks when you do it via SetParent?

tepid brook
#

yes

heady iris
#

won't it spawn at some random position you don't want?

tepid brook
heady iris
#

set the local position after setting its parent

#

it's called worldPositionStays, not localPositionStays

tepid brook
heady iris
#

what are you spawning?

#

set its local position after setting its parent

tepid brook
#

This is my code

#

_first = RoomMap gameobject

heady iris
#

so yes, set the local position after parenting the transform

#

local position is your position relative to your parent

swift falcon
#

sorry if wrong channel, but what the hell is this?? its not letting me build my game.

#

playmode works okay, then i try to build for android il2cpp, it shows those two errors, and playmode stops working

somber wraith
#

Weird.

swift falcon
#

2021.3.22f1

leaden solstice
#

It says your script has error

swift falcon
#

those two errors

leaden solstice
#

Does it have any other log when you click it

swift falcon
#

nope

leaden solstice
#

Just empty?

swift falcon
#

theyre just there, i click, double click, right click, nothing

#

yes two empty errors

#

it also asks if i want to go to safe mode when i open the project

heady iris
#

that means you have compile errors.

leaden solstice
#

Try safe mode

swift falcon
#

it goes into playmode successfully

heady iris
#

see what is being reported.

swift falcon
#

dont know if this fits the topic, but i dont have roslyn and unity_csc.bat* in my unity tools folder

leaden solstice
#

In Unity installation?

#

You donโ€™t have compilers? That sounds little unlikely

swift falcon
#

C:\Program Files\Unity\Hub\Editor\2021.3.22f1\Editor\Data\Tools

#

no unity_csc.bat

leaden solstice
#

But probably worth trying reinstalling Unity

swift falcon
#

and no "roslyn" folder with csc.exe

#

its a clean installation but ill try anyways

#

also on project load sometimes it shows 'the file memorystream is corrupted remove it and launch unity again [position out of bounds!]' and only opens after trying again

heady iris
#

a new installation, perhaps

#

but not a clean one

swift falcon
#

yeah i just installed it

leaden solstice
#

Sounds like bunch of issue going on

#

Reinstall & Reimport all & Pray

swift falcon
#

also is InputShutdown supposed to take 3 years to complete when im trying to close unity?

#

oh hey new errors

empty hollow
#

Hello, I'm using the interfaces IPointerEnterHandler, IPointerExitHandler in some script but when building for mobile it gives me warning.

Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.

However, if I put the interface implementation in conditions (#IF_STANDALONE..), it then says that interfaces are not implemented when I switch to mobile platform.

Any way of solving this ?

leaden solstice
swift falcon
#

yeahh but still dont make sense to me

leaden solstice
#

I think you should try different machine

#

And see if it is reproducible

swift falcon
#

you mean use another computer and build it there?

leaden solstice
#

Yeah

swift falcon
#

i think a vm will work

leaden solstice
#

Probably

leaden solstice