Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
C# is a multi-paradigm, managed, strongly typed, garbage-collected, programming language created by Microsoft in conjunction with the .NET platform.
0
votes
Accepted
Generic shape design
Selecting the Intersection Method
Class IRdelegateCollection uses a "jump table". My implementation needs a _jumpTable.ContainsKey(typeof(U)) check for both setting and getting. Is there a be …
7
votes
Accepted
Store functions with parameters in a List
You declare that you have a list of actions:
List<Action> list;
Do not forget to initialize it:
list = new List<Action>();
Then, you create an action from the function using a lambda expression: …
1
vote
Iterate over a loop to calculate a sum, or update a sum variable as items are added and dele...
Regardless of the approach, you will need code with the responsibility to do it correctly. And you want that code to be in a single place.
Why a single place? On one hand, if it has any bug, you only …
1
vote
Can a generic class inherit from MonoBehaviour?
The code you present is valid C#, yet as far as I know it is not supported by Unity (giving a "Generic MonoBehaviours are not supported" error warning on the console when trying to use AddComponent fo …
0
votes
What to use if you want a looping list?
A circular buffer is simple to implement, you can do it as Philipp suggest or you may - for example - use index % array.Length to query (unless the index is negative).
Remember that accesing a negati …
4
votes
Which method for creating a Loot chance, int or float?
We are talking C#, so I'll assume .NET. Thus you would either use System.Random.Next which works with integers, or System.Random.NextDouble which - as the name suggest - works with double. There no me …
1
vote
Detect Mouse Enter on An oval shape image in unity
Assuming you have the bounding rectangle that wraps the ellipse. There is a transformation from that to a circle. You can create the transformation that maps that rectangle to a square.
You can use it …
1
vote
Accepted
Are there feature/performance/platform limitations when using the Mono/C# version of Godot?
There are likely some bugs because it is a new feature
C# - the language - is well supported. Also, a lot of effort have gone into supporting ahead of time compiling, which allows greater platform s …
4
votes
Accepted
(C#) Need help with Shuffling a list
Your loop condition is while (n < 1).
Since n is integer and initialized to IList<T>.Count, which – on a good implementation – can't be negative. It means that the only value of n that satisfies the …
2
votes
Accepted
How to check which Area2D's are overlapping with KinematicBody2D?
This is much easier starting with the Area2Ds. You can query each Area2D with overlaps_body. Something like this:
var areas := [$Area, $Area2] # perhaps get the list from somewhere else
for area in ar …
24
votes
Accepted
Avoiding string literals to reduce memory allocations
A string literal in C# will be compiled to string literals in IL.
Then the IL is compiled to machine (or to C++ and then to machine code if you are using IL2CPP).
On machine code the strings constants …
3
votes
Accepted
Fastest way to look up an entity with a set of components?
Update
I have wrote Theraot.ECS inspired by this answer. It allows you to use Guid, int or whatever for the entities. It will allow you specify how sets of component kinds are handled. Two implemen …
8
votes
Accepted
How to wait until the frame is done?
Disclaimer: Mono Build? I haven't tried at the time of writing.
This is the GDScript 2.0 you would be trying to mimic in C#:
await get_tree().process_frame
Thus, I believe in C# it should say:
await …
3
votes
Is Time.deltaTime the last frame time or it is the time difference between frames?
This property provides the time between the current and previous frame.
That definition is correct. We can argue that it could be clearer.
In layman’s terms, delta time is the amount of time your …
2
votes
Accepted
Procedurally Generating Locked Doors
Doors and keys (or switches, or puzzles, or whatever is used to open them), have a very simple rule: The player must be able to reach the key without crossing the door.
Ergo, if you decide, at random, …