#archived-code-general
1 messages ยท Page 140 of 1
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.
how would this MonoBehaviour question help with that? ๐ค
Because I could access the variables on that script?
you can access variables on any script
any component
regardless of whether it's a MonoBehaviour
I added public variables on the TMP_Inputfield and I couldn't find them
what do you mean by that
how do you add variables on TMP_Inputfield?
Are you trying to modify Unity's built in classes?
TMP_InputField uses a custom inspector
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
okay I appologise I guess I am too in over my head
InputField has events for when things are typed into it. You can just subscribe to those events
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.
remove that last comma on the second line.
it is public class WeightedList<T, W> : IComparable, ICollection where W : <whatever constraints>
oh, thanks
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);
}
}
did you create a new asset bundle for the selected object(s)?
Not an answer to your question unfortunately but the if statement around CreateDirectory isn't necessary. CreateDirectory will always do the right thing
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?
{
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
when you sub a method of a struct that is a member of a class to an event, what exactly is happening?
just reference them directly, why do you need GetChild
I cant apply the instance in the inspector because im going to have these as a prefab
GetComponentInChildren<Toggle>() will always return the first result, I believe Depth-First. so checkmarkToggle = GetComponentInChildren<Toggle>(); You can also use [SerializeField] to make variables to hold those references and link them up in the inspector.
You can set the linkages within the prefab; use [SerializeField] (or make them public) to view them, and when you're editing the prefab, just link em up, and it'll be maintained for each instance.
I was thinking about external references in the editor
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.
yes, you can create a component that flags your Toggle
and then just GetComponentInChildren
or, if its a prefab, make root component that stores references for prefab internals
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.
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?
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
removed IDisposable just in case, same thing
any ideas are welcome, its either a bug in clr or i dont understand something
I would place the Weapon Display Info GameObject as a reference on a variable in another script, like a singleton, then access the singleton to get its reference . . .
im only going to need 1 reference so that wont be necessary
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
When you write something similar to: namespace XXX {ย ย ย ย ย ย public struct SomeStruct ย ย ย { ย ย ย ย ย ย ย public event SomeDelegate SortDirectionC...
maybe due to how structs are copied, is it creating a new struct at some point
ah that link suggests the same
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
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.
just create a camera rig from chain of transforms
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
i'd really prefer to do it the quaternion way ๐
ah forgot about springs
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.
Do you mean to revolve a camera around a point?
transform.Rotate(transform.forward, amountToRotate);
๐คฏ
public static Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
{
return Quaternion.Euler(angles) * (point - pivot) + pivot;
}
thank you
this only did what i expected after setting the space to Space.World. why is that? i thought rotation spaces generally only matter in hierarchies.
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!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
The entirety of it gets reset, even a color field. I don't get whats happening.
This is not a scriptable objects though.
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?
Ah, if you're editing it via code that might be the issue.
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.
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
Yes, because the editor is viewing the object in the memory.
anyone know how to add a space between the bars in the code?
this is the code
https://hastebin.com/share/oteberenij.csharp
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
well fuck
I'll try it out n see
I configured the x,y,z positions and speed but I dunno how to add space between
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.
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
Yeah, SerializedField is just an attribute to make the field serializable. It doesn't handle saving the changes for you. SerializedObject is a wrapper to an object field, so that if you make any changes to it, unity should handle the serialization/saving.
It should be used for the references I think. Haven't messed with editor scripting that much.
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
You said that you modify them via code though?
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
Try the SetDirty then.
and it kept the data
so it most definitely is this issue
looks to be fixed, thanks @cosmic rain
by removing 1 line of code which is literally just an if statement with nothing inside of it, I stopped multiple lines from a different function from printing
this is super weird does anyone know why this is happening
Show if statement that you removed ;)
i commented it out
Oh wait its a video
yea
Okay so an if statement without curly braces
And then a statement
Will be interpreted as a if with a single line in there
i tested it with a simple print too though also
Hello guys, where is the best way to ask for help, but not code wise, more about Unity - Xcode compatibility
if(something)
Debug.Log("something");
yeah i did that too and it still happened
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
i did it with an if statement with braces and the problem still happens
Code please
its not supposed to be in there though
Becuase that's the line that's conditionally ran
oh
Look at this
oh yeah it worked
This is why you should always add curly braces
If you don't add them it'll just assume that the next valid statement is part of the if
You are welcome
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
How about trigger colliders at the edge of each platform?
If overlapped, change direction
thank you, i will try that
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
It is an option on rigidbodies so they appear to move smoother
Well thank you for your help, you probably just fixed an issue that I had for months
is there a way to change exit time of a specific transition in runtime
by in runtime i meant in code
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
You are manually setting the velocity, which will essentially get rid of their current velocity
You should add to the velocity instead of directly setting it, and also limit the max speed for sure
You probably should also look at beginner tutorials. U really dont need to set its constraints every single frame, or check if(bool == true) because a bool is already true or false
I've been trying but im struggling to keep my attention on the tutorial because it s a whole lot of listening and not a lot of doing and my concentration is at a low sooooo im really struggling to do anything
You can always use the unity learn site then which is more interactive. Though with coding, you'll pretty much always have to learn something new
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
im in a c# course and ive been using brackeys but im still lost at the end of the day i might take a untiy course eventualy
i iwll
I'm struggling understand how to add to the velocity
Brackeys is very questionable in his coding, I would suggest a different channel but I really just havent watched any good beginner ones
There is a addForce function, or you can manually add to the velocity with
+= Vector....
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
ive also tried code monkey but it looks liek most of his tutorials are on his site
ok thanks
ive been playing around with boht oprions and neither of them seem to work, manually adding velocity seems to work better but the player still slows down when moving left/right
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.
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
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;
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 ...
Math shows very high gravity at the start (around -200) and then decreasing, shouldn't it be the other way around?
When calling a method, you don't need to specify the type
then how should i do it ?
everywhere i looked it told me to do it like this
i don't need to write anything in test() ?
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
then i should just need to specify master in it right ?

i did already
Then we fixed it
You know these images don't help, we need more information
A stacktrace, error message, something like that
||waiting for my turn to ask a question...||
The name 'identifier' does not exist in the current context
I do, you have not declared master as a variable
but somehow it wasn't a problem when declaring parameters for the method in itself ?
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.
parameters are not variables
You can ask
Who could I DM? ๐
I recommend focusing on #๐ปโcode-beginner
The problem is better suited there so it's more likely you get appropriate help
Sorry, but we are not here to help somebody get used to c#, because there's no point in doing that since there are plenty of resources online for this. It is way easier to start with the basics of c# instead of starting with Unity while you have no experience with c# in general.
no one, make a thread
i came here as a last resort, dw i'm used to being asked to fuck off, i would'nt come here first
I'm new to this ObjectPool class thing: https://docs.unity3d.com/2021.1/Documentation/ScriptReference/Pool.ObjectPool_1-ctor.html
My question is, how do I create a new pool object that is a prefab, instead of just new GameObject(), using the createFunc parameter (I'm not pro at Unity).
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)
forget it, i'll ask chat gpt
ChatGPT is pretty good for Unity IME.
This is terrible advice
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
neither are unclear outdated wikis
best teacher is another person
but somehow they always bounce you for trying to learn
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
i'm talking about absolutly anyone when you ask for help, so many forums start by sigh have you even looked it up ๐
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?
That's because Googling is a whole skill by itself, and very often the literal question you ask can just be Googled
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
What's your coding experience level?
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
I agree, people are very easy with giving you a terrible, often even outdated, answer. Very often they also prefer to fix something that isn't a problem, instead of helping you with the thing you came for
It sucks to hear, but you're going to want to learn how to code before you try to mix code and unity. I'd probably start with python, then move on to C#. In the process you are going to have to develop your Google-Fu. The first few months of learning to code suck hard, but if you grind it out it'll get a lot easier and you'll have context for the tutorial and the docs.
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
If you check the pinned post in #๐ปโcode-beginner , there are resources to help you get started with c#
https://www.udemy.com/course/the-modern-python3-bootcamp/
This one costs $30 on sale, is well structured, and you can knock it out in a month. You'll get a good feel coding, including all of the ideas revelvant to C# besides visibility and typing. You'll learn so, so much faster than trying to piece things together yourself.
why python first tho
It removes a lot of overhead IMO.
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.
I spent a month watching tutorials on coding and then it just snapped into my head out of nowhere.
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
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.```
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"```
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? ๐ฆ
can i do some kind of addforce to the cc ?
to move Character Controller you need the built in move methods
i figure it out
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
i just want to use rb.addforce but since i have a charactercontroller atttached to that gamobject i can't
Did you check that OnRotate is being called?
uhh guys i thought if i select everything so it should be able to place every item type :/
idk how to google it tho
!code (just for i wanted link fast lol)
๐ 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.
me?
no lol
i wanted link for myself to pastebin
:D
but realized i can do it without
alright
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
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
fun(arr)
{
foreach(...)
if(...)
return true;
return false
}```
actually using 'object's wasnt good solution, so im still avaible for ideas
Why is object bad?
wdym bad?
Sorry, i meant as a reply to @uneven monolith
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
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>)
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
Ye thats another way
Why do you need something like that in the first place (just curious)
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)
I don't understand the "i can turn any class to ScriptableObject" part
why not make ScriptableObject classes in the first place?
I could type out some examples of how to do what I think you're trying to approach, but basically it sounds like you're wanting some kind of Factory pattern
Also, doesn't scale well, but why not have static factory methods on your different SOs?
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.
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?
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.
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.
yeah, I gonna try debugging it rn
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
is this because every camera is rendering gizmos so if I use 2 cams I have 2 times the gizmos?
I doubt that's supposed to happen
You could try disabling gizmos from the game window
well then all gizmos are gone, but if you want to have gizmos enabled you see every gizmo twice
this is a code chan, you doing anything with gizmos in code?
nope but didnt found a better place to post
well thanks mate
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
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.
It's a multiplier. A pitch value of 2 will result in half the length.
oh
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
wait a second. What would be the value of 0 or -3 mean then?
this is a default slider
huh??
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
define "doesn't work"
and explain what these datatypes are
because nobody can tell just from this context-free code
are these animation curves?
https://docs.unity3d.com/ScriptReference/AnimationCurve-keys.html
Note that the array is "by value", i.e. getting keys returns a copy of all keys and setting keys copies them into the curve.
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
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
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
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
that's such a shame. I guess a class works as well
yes - but for consistency, I have defaults for all variables. Many of them have different, non-default defaults.
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.
yeah, I got it. Was just surprised that negative playback has 3x range vs speedup
(also very annoying it's not semitones)
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
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???
remove the public modifier from the 2 variables you declared
what's the difference between
where T : notnull
```and```cs
where T : struct
```?
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 soint?would be valid for the second one but not the first
hmmm seems struct also specifies non-nullable value type ๐ค
but the difference is that notnull can be a reference type whereas struct can only be a value type
IK thought reference types can't be not null
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
ah
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
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.
!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.
just FYI, if you don't get a response in #๐ปโcode-beginner then reposting your question in this channel doesn't mean you're any more likely to get a response. not getting a response could be due to lack of useful information that might help troubleshoot your issue. see #854851968446365696 for what to include when asking for help
ok sorry
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
use the profiler to determine where performance issues are coming from
Are you constantly creating and destroying the enemies or are you using a pooling pattern with them?
im constantly creating and destroying them
The profiler should nail down what scripts and methods are creating the problem . . .
the profiler said: playerloop
turn on deep profiling
I'd definitely use object pooling for the enemies, especially if they share common stats/behavior . . .
Sorry, forgot. Always use deep profiling โ it's invasive as fuck . . .
```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?
you'd have to show the rest of your code
it's unclear what you are doing with this variable
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);```
i think you have your x and y mixed up
wait maybe not?
wait yes it's mixed up
you should be clamping the x rotation
i am clamping the x rotation
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?
if i put the value in 50 and 10 or -60 and -10 it clamps correctly
ok yeah sorry - i think that's ok. But you're subject to gimbal lock doing things this way
yeah because you're doing this based on reading the euler angles back from the transform
that's not going to work properly
you might get -15 or you might get 345
they're equivalent
so how do i fix it?
you need to drive the rotation with your own variable instead of teading it from the transform
I did use var, and when I attempt to treat the object like a List, it treats it like a Triangle object
uhm, can you maybe explain in a more noobish way :))
For some reason it's identifying the object as the wrong data type
I don't understand why
Hover over map, what data type does it highlight?
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);
}```
It's very clearly defined in the class field as being a List<triangle> object
whats wrong with deltatime?
mouse input is already framerate independent
adding it here is going to make it jittery and weird
you are foreaching the list there, so each individual element is a Triangle. if you were just doing something like var list = map[key] then yes, the data type would be List<Triangle>
No, in the foreach
alrighty
But yeah, you're indexing the dictionary, which gives you a list, then foreach iterates over the list, giving you a Triangle
works perfectly, ty โค๏ธ
what is the type of map[key]
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
right. so what do you get when you foreach a List<Triangle>
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
stop using var
it's making your life hell
because you don't even know what type your variable is
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
yes this shows that the type is wrong more clearly
var gets rid of the compile error at the expense of you being confused
becuase Triangle is what should go there
So I should be doing "in map" instead of "in map[key]"
what are you trying to do
foreach ((Vector2 key, List<Triangle> value) in map) {
foreach (Triangle tri in value) {
}
}

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 ?
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.
So how do I loop through all the keys and get the list itself
just like how I showed?
notice the triangles variable is a List<Triangle>
that's the list you want, yes?
Couldn't you just loop through all the values and acquire the lists?
Ah I see what you mean now
will a serialized C# dictionary deserialize into a std::map?
depends on how you serialize it and deserialize it
if the serialization format and CPP library for deserialization are compatible, sure
How to make that effect. It's all 3D objects around even dashboard with shifter and steering wheel
How he's highlight it
Doesn't look like a coding question.
Try asking #๐ปโunity-talk
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();
})
you can definitely use a loop
why is it that when I import my model it's not the right way round?
var operation = action.PerformInteractiveRebinding(bindingIndex);
foreach (string exclusion in exclusions) {
operation = operation.WithControlsExclusing(exclusion);
}
operation = operation.OnCancel(blah blah blah);```
The "Does not exist in the current context" error means you tried to use a nonexistent variable somewhere.
not a code question. #๐โart-asset-workflow, but basically you exported it wrongly for Unity
probably change your export settings, but ask in a channel more related to assets..
sorry
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
you missed something on line 69
Line... 69?
oh sorry, since you didn't provide any actual information i assumed you just wanted us to make random guesses
default(int) // 69
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:
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?
I know handles are a special class, like they are an editor only class right?
that would make sense but I'm in editor..
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
and, this wasn't an issue prior to upgrading to 2022 LTS
share the entire class using a bin site ๐ !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.
very unlikely that it has anything to do with the number of things that reference a particular function
I can, I'm just not sure why any of it would be relevant. Like the code compiles and runs, I'm just wondering if anyone knows why the editor suddenly complains about not finding the handles class
Any idea why I could be getting higher compile times than usual? I have all the same stuff as my last game, URP, TextMeshPro, etc
I tried messing around with Assemblies but tbh my game is pretty messy with dependencies, not much I can do.
It feels like something is wrong though, my game isn't big enough to have compile times this large yet
compile time, or build time?
Compile time, making a change to a script and then entering the editor
Do you make use of namespaces?
No do you think that would help?
Ofcourse
If I change the value in the project settings will it automatically update all my scripts?
namespaces are irrelevant to compile times. it's assemblies that help reduce compile times
May not make much difference if there isnt much code Oops ye my bad, namespaces dont matter.
Apparently I can just #if UNITY_EDITOR the whole section and it works, although the code does get called from the editor
Here's my github for the project, I don't expect anyone to properly look through it but if you have an idea of a possible problem you could check here:
https://github.com/CloudyUnity/dreamstar-terminus
sounds like somehow it's compiling for a build not for edit mode
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
if you're doing a build, then it will of course fail
Handles has never been accessible in a build
yeah, you should peek at the symbols that are defined
that's odd then, yes
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
I've seen a few mentions of disabling "Reload Domain"
This is disabled right? This was the default for me
and if editor fixed the issue so.. maybe I'll just be more careful
lemme check this
This is the default setting.
Reload Domain and Reload Scene are both going to happen.
i would strongly recommend against disabling domain reloading if you don't want to manually reset your static variables
You can also have problems with some packages.
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
I have the same here as you do
appears to be my default settings
enable play mode options and nothing else
Didn't seem to make any difference anyway, still about 30 secs
and it will disable both reloads
Get more RAM or better CPU ๐ SSD would help a lot.
If you made a completely new project with absolutely zero assets, scenes, ect, and made just 1 single script in the room Assets folder with nothing else, then make a change, about how long is your compile time then? If its somewhat close, it may be a different issue than asset-specific
@swift falcon tho i advice to keep scene reload enabled
My previous project was waaaaaay bigger than this one and is ~18 secs compared to ~30 secs
so did you do it? its works?
Yeah I did what you said there, took about 3-4 secs off but nothing major
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?
why new project
new scene
in the same project
the gains of "compile time" by unity are marginal
Is your project on SSD? or HDD?
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
New scene: 35 secs
New project: <5 secs
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
Not to enter playmode. If I change a script, save and then re-enter Unity it takes 30-35 seconds before I regain control
It really depends on PC specs too
That was with Play Mode Options disabled
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
i'm not sure if there's a way to profile what's taking up time in the compile -> reload process
domain reload what else
well, yes
and that is affected directly by drive/cpu/ram
but the question is whether something is taking up an abnormal amount of time in that process
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
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
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
Can always call this in editor code to see if your compilation takes long CompilationPipeline.RequestScriptCompilation();
Sorry that took so long, using a stopwatch it took about 41.54 seconds
Which seems a bit insane
Is the project on SSD?
how do i make mesh data (verts / triangle) in a unity job from a noise map
It is yes
I want to bring attention back to my first thought, are we sure this web of dependencies is not a possible cause?
Assuming all my scripts are under the one assembly the compile times shouldn't matter on the dependencies right?
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?
unfortunately these numbers are irrelevant
only you, it's your computer
Only thing I can think of is if you've got assembly definitions referencing the Singleton, modify the Singleton would have all dependencies recompile.
The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: https://skl.sh/gamedevguide05211
Learn how to get back into the Editor faster after making changes to your code by using Assembly Definition Files in your project!
Gameplay Logic using Bolt: https://youtu.be/tP9_YBpBBpI
Attributes and Reflection: htt...
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
multiple days 
I almost said did you close the project recently
Well thanks everyone for the help anyway lmao
well, more generally, if you modify an assembly, all assemblies that depend on it get recompiled
singleton or otherwise
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
i'm bad about not committing partway through an implementation
i should just squash them before pushing
just commit, no need to push
I quite like perforce because of that, its all CLs no commits ๐
in the morning you can push it in a new branch if needed
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?
full 3d?
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
Like minecraft
minecraft doesnt have fow
Yes, it can contain float voxels as well
yes that i understand my question still stands
full 3d fow means you have full voxel volume to process, with problems like occlusion
I think it does not work in my scenario
yes, adding that extra degree of freedom leads to...
fun (tm)
It is full 3d voxel game with sparse voxels in different heights
its going to be a nightmare
there probably is some whitepaper with efficient algorithm for that
something along bresenhams line but for 3d
Also, if a voxel gets visible, it will be visible forever
still
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?
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
You mean to hide/show items on voxels or just render voxels as black voxels or normal voxels?
to flag voxels and not flag occluded voxels
rendering that should be relatively easy
you can use Texture3d
Yes, just set black color to hidden voxels is really easy but showing/hiding 3d items, enemies, npcs on those voxels are nightmare
check stencil occlusion
thanks
or easier
you can sample the nearest voxel
if the voxel is visible so is the object
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
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
:/ but it would not be ideal. Suppose an enemy moves from a hidden voxel to visible one.
and what happens?
It renders completely after going to the visible voxel
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
I mean the model (mesh) is completely visible or hidden not parts of it hidden and the other parts visible in voxel edges
in a job, and on a separate voxel structure that only stores visibility flags
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.
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");
}
}
Store a copy of the original bindings. When you remove all bindings, assign the original copy back . . .
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
Oh snap! This is really cool, thanks!
Just do note the caveat that it only works with Mesh Colliders
Hi!
Gotcha
I'm trying to use this to detect the colors directly under the player but for some reason the color it's detecting doesn't properly align with what's under the player. It seems to be offset and scaled for some reason
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;
}
}
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
Ah, I thought C# had a garbage collector that would just handle that
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))
Hi guys. Do you need any help with your sprite creation? I like helping.
!collab
We do not accept job or collab posts on discord.
Please use the forums:
โข Commercial Job Seeking
โข Commercial Job Offering
โข Non Commercial Collaboration
thanks
Damn, I should get you to do a code review for my whole project lol
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
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
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
you must know which space you're working in
for any Transform, you can convert from world -> local and local -> world
in this case, everything was done in world space
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
This would be the most straightforward way to do it.
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?
well, I would recommend just using Cinemachine
hm...
it's a great camera control package
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
you don't have to move the cinemachine virtual camera yourself
you just use the Transposer mode
This is not very notorious for low velocity, but it is a problem for velocieites with a magnitude > 1000km/h
ok ok, let me check
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.
Use the memory profiler to see what's actually in memory https://docs.unity3d.com/Packages/com.unity.memoryprofiler@latest/
You've probably screwed up and are not destroying meshes you've made previously
Gracias
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
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
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.
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
Whoa, i've just learned something after literally years that sounds quite important 8)
There are other things that allocate new objects, like calling render.material, and it's also up to you to destroy those materials too
Would GameObject components count as UnityEngine.Object stuff?
That'd do it
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
So in this case, should I be calling "color.Destroy()" at the end of the function
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.
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?
It only applies to mesh properties
Many properties on UnityEngine.Object subtypes will have similar behaviour though
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
In this screenshot you can see the console that is showing RGBA value at the specific point (0.7, 0.64) and on the bottom right is texture it's pulling from. I did the math based on the pixels but it's still not adding up
Based on the hit.textureCoord that's getting logged, the RGBA value should NOT be all 0's here, yet it is
I'm suspicious that this texture is 1024 while your code is 512
what do you mean the code is 512
#archived-code-general message
Texture2D tex = new Texture2D(512, 512, TextureFormat.RGB24, false);
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
OH! I'm so stupid, that line should have been Texture2D tex = new Texture2D(rTex.width, rTex.height, TextureFormat.RGBA32, false);
I just changed it and now it works!
Thank you so much!!!
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
I guess here
Any of the code channels
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
Have you found the documentation?
I'm afraid I don't know what a DoTweenAnimation is, so I can't help
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
Yes.
Best to also show the code
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));
How to fix "The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)"
do you have Json.net installed?
Idk why but changing header file to using Unity.Plastic.Newtonsoft.Json; worked
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
It'd be pretty strange to have your game logic depend on a version control package. You should add the com.unity.nuget.newtonsoft-json instead, if you haven't already
I probably sound stupid Iโm sorry haha I just need help with a new script for my movements.
Ohh, can I just add it through packagemanager?
Yeah I could, thank you
You'll need to share your !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.
I still get this error tho
You may need to restart your IDE
{
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
Ah right that worked
Gotcha! Give me a couple mins and I will! Thank uโ
you can just encrypt the string. Also 2 lines of your if statemnet happen in both conditions so u can just take it out
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
do you know of a encryption system that works univerally
should be able to use this, and just encrypt your string itself
https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=net-7.0
though I would at least look at a high level overview of how encryption works, for whichever algorithm u choose. AES is popular
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
ik
HERE MY code, im trying to code movements on my game but i cant even move or look around
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Don't crosspost
Stick to one channel
https://stackoverflow.com/a/4313447 Maybe this?
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
Namespace it? 
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
Is it just me, or the screenshot on this docs page is wrong? Shouldn't the transition be from the bounce state to the rest state?๐ค
https://docs.unity3d.com/ScriptReference/Animator.Play.html
Hello, kinda wierd question but what you think would be better name for showing additional windows in UI:
- ToggleWindow(bool)
- ShowWindow(bool)
- TurnOnWindow(bool)
ShowAdditionalWindows(bool)
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
Yea I agree, just had trouble wrapping my head around but got to same conclusion. Thanks! ๐ฆ
is there some non alloc version of GetCustomAttributes?
allocating an array for each type in the project is overkill, what is this api
If I remember correctly you can just call it on the assembly itself
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);
can i check just a dot for a collision and not an entire ray?
yes u can, 2d or 3d though?
3d
you would be checking more if a point was inside a collider
Physics.OverlapSphere(some position, 0f) should work
what do you mean
you can check if the OverlapSphere hit anything, and i guess u could also just use the nonalloc version
https://docs.unity3d.com/ScriptReference/Physics.OverlapSphereNonAlloc.html
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 !
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 ๐
One needs a rigidbody, but you can set it as kinematic
So if one is a door and the other an enemy - Would the enemy have the Rigidbody? or does not matter?
(Thank you)
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
That's useful - Did not know that. Will give it a spin ๐
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
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
If anyone is interested, I did find a solution, I'll tell you if needed.
Thanks anyway.
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?
oh mb
You probably get a quicker answer there
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
You can't keep references to a scene from another if it's something unique in the scene.
If it's a int, or a string you need, create a value in the script you put on DontDestroyOnLoad and assign the value from the first scene to the value on this script, it should work.
If it's a game object, I don't really know, use a prefab maybe.
Good afternoon! 
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! ๐๐ฝ
So, are you asking how to serialize a game object without specific components
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.
EditorApplication.playModeStateChanged
anything that executes after i click Play but before the game launches ?
This one executes after game launches
I suppose I know how to do it, but I would like to hear your proposition, yes. Same for script attached on a gameobject that I no longer want to be attached to this gameobject.
You can't modify the scene in a built game.
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
But I need it the first time the game is played, right? Am I doing the thing the wrong way?
I don't know what your use case is.
I gave an exemple here
You'll have to flag it for when you deserialize the data you'll know not to create the GO with that specific component
ah, I didn't read it, whoops
๐ซ
I would suggest having a component that checks if this is the first time you've played
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?
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
It does have a state before it launches but make sure to check if(!BuildPipeline.isBuildingPlayer) to handle your case correctly as it also calls when building.
(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!
^^
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...
no, you should just have a "tutorial spawner" component whose job is to check if the tutorial should be spawned
So, for each script or gameobject I want to instantiate, I need to have another script on another gameobject that will do the spawn?
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
Mh... So, as we said, I should hard-code the conditions and logic to instantiate in a dedicated script. Alright, thanks again!
it does seem to work thanks
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???
okay, so now you're asking about a whole save-game system
that is a significantly harder problem
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
Again, the tutorial was just an exemple. Excuse me for the misunderstanding.
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 ?
i've try with true and false and its same
the entire point of worldPositionStays is that the world position stays
Was thinking. I already have a save-game system. I just need to know a way to save the gameobject to destroy in a save file. Is [SerializeField] enough to get the gameobject on load?
[SerializeField] just tells unity to serialize a field on an Object that would not otherwise be serialized
e.g. a private field
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)
if you're looking at the Transform component in the inspector, that shows local position/rotation/scale
@leaden ice Look who i just found on them Unity forums hahaha
Not exactly a rare sighting ๐
I see but for me it was lol
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
Sounds reasonable.
oh wait
why's fixedDeltaTime in there?
you're setting the velocity, not adding to the position
Yeah thats what i was looking it myself, should I just remove it and not use any times there?
alright
I just thought the input value would change quicker based on the framerate, but i dont know
it's going to be a number between -1 and 1
yeah, wouldnt the number change quicker? but yes removing the time makes it good still
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
oh yeah
if you want to make your velocity change non-instantaneously, then you'd need to do something in SetVelocity
Ive used GetAxis all the time but I still ask such goofy questions lol
deltaTime doesn't cause stuff to change smoothly over time
it just converts "X per frame" into "X per second"
So, we come back to my initial question: is there a value I can store in my save file and that let me find the gameobject on load
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
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?
Depends on in the scripts are related and/or how many instances exist of the logicscript
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?
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
System.IO.Directory.GetFiles("path").Length
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
its just one script of each, and they are in two different objects on the same scene, LogicManager and Bird respectively, and they are there from the start not spawned or instantiated later
I would say add a SerializeField on the bird and assign logicmanager on it
ok let me try that
Can someone help me to change the parent of an object and keep its position like in the hierarchy ?
lets goooo it worked
.
the local position, rotation, and scale will change when you call SetParent with worldPositionStays=true
i know but that not help me
that is expected
If you're parenting it to a non-uniformly-scaled parent, then that could cause distortions
my problem is the position not the scale
when i drag my gameobject to the parent in the hierarchy its work
perhaps you can show what's happening
sure
thanks, i will try it
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 ?
seems like a z-fighting issue
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)
oh, these are UI elements
with rect transforms
are you sure you're getting an identical hierarchy layout
i don't know what is this sorry
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
this is my hierarchy and the line spawn on RoomMap and setParent to MapImage
and is that exactly how it looks when you do it via SetParent?
yes
wait, you say that you're spawning it, then setting its parent
won't it spawn at some random position you don't want?
Yes i spawn it in RoomMap and set the localPostion to (0,65,0) and setParent to MapImage
set the local position after setting its parent
it's called worldPositionStays, not localPositionStays
Room parent or MapImage parent ?
so yes, set the local position after parenting the transform
local position is your position relative to your parent
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
Weird.
2021.3.22f1
It says your script has error
those two errors
Does it have any other log when you click it
nope
Just empty?
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
that means you have compile errors.
Try safe mode
it goes into playmode successfully
see what is being reported.
dont know if this fits the topic, but i dont have roslyn and unity_csc.bat* in my unity tools folder
But probably worth trying reinstalling Unity
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
yeah i just installed it
also is InputShutdown supposed to take 3 years to complete when im trying to close unity?
oh hey new errors
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 ?
Cool it has some text at least
yeahh but still dont make sense to me
you mean use another computer and build it there?
Yeah
i think a vm will work
Probably
You can #if the interface list ๐