This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class SelfCreatingPrefab : MonoBehaviour | |
{ | |
private int fieldA; | |
private int fieldB; | |
public SelfCreatingPrefab Init(int arg1, int arg2) | |
{ | |
if (!gameObject.scene.IsValid()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
[AttributeUsage(AttributeTargets.Field)] | |
public class PrefabOnlyAttribute : PropertyAttribute { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.Beep(523, 300); | |
Console.Beep(587, 300); | |
Console.Beep(659, 300); | |
Console.Beep(698, 300); | |
Console.Beep(587, 900); | |
Console.Beep(783, 300); | |
Console.Beep(880, 300); | |
Console.Beep(783, 1200); | |
Console.Beep(523, 150); | |
Console.Beep(587, 150); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Orioginally by maybe_an_username | |
// https://www.reddit.com/r/PowerShell/comments/q8l24k/some_powershell_beep/ | |
Console.Beep(196, 1200); | |
Console.Beep(196, 300); | |
Console.Beep(220, 400); | |
Console.Beep(196, 400); | |
Console.Beep(174, 300); | |
Console.Beep(155, 1000); | |
Console.Beep(146, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Originally by Shensd | |
// https://gist.github.com/Shensd/01342e2f399de4dca2ca87b36059ba0a | |
Console.Beep(369, 200); | |
Console.Beep(369, 200); | |
Console.Beep(369, 200); | |
Console.Beep(293, 300); | |
Console.Beep(246, 200); | |
Console.Beep(329, 250); | |
Console.Beep(329, 200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scene physicsScene = new Scene(); | |
var go1 = physicsScene.Instantiate(); | |
var rb1 = new Rigidbody(go1) { Gravity = 0, Velocity = new Vector2(0, 1) }; | |
go1.AddComponent(rb1); | |
go1.AddComponent(new Collider(rb1, go1, 1)); | |
var go2 = physicsScene.Instantiate(); | |
go2.transform.Position = new Vector2(0, 10); | |
var rb2 = new Rigidbody(go2) { Gravity = 0, Velocity = new Vector2(0, 0) }; | |
go2.AddComponent(rb2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Managed managed = new Managed(); | |
await Task.Delay(1000); | |
Console.WriteLine("managed is now null."); | |
managed = null; | |
Console.WriteLine("press any key to make the GC collect"); | |
Console.ReadLine(); | |
GC.Collect(); | |
Console.ReadLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Diagnostics.CodeAnalysis; | |
int capacity = 10_000_000; | |
List<Vector3NoEquals> Vector3NoEquals = new(capacity); | |
List<Vector3WithEquals> Vector3GoodEquals = new(capacity); | |
List<Vector3WithIEquality> Vector3WithIEquality = new(capacity); | |
for (int i = 0; i < capacity; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Console.WriteLine("Creating 50 NotDisposable objects which will" + | |
" allocate 500mb of memory and will not clean at garbage collection."); | |
Console.ReadLine(); | |
if(true) | |
{ | |
NotDisposableContainer container = new NotDisposableContainer(); | |
container.ND = new List<NotDisposable>(); | |
for (int i = 0; i < 50; i++) | |
container.ND.Add(new NotDisposable()); |
NewerOlder