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; | |
public class DelegateExamples | |
{ | |
public void Run() | |
{ | |
Action action1 = delegate { /*Do something*/ }; | |
action1(); | |
FunctionWithOnComplete(action1); |
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; | |
public class EventKeywordDemo | |
{ | |
public event Action<int, bool> event1; | |
public Action<int, bool> action1; | |
public event EventHandler event2; | |
public delegate void SampleEventType(int param1, bool param2); //Equivalent to Action<int, bool> |
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
// Decompiled with JetBrains decompiler | |
// Type: AsyncAwaitTest.Program | |
// Assembly: AsyncAwaitTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | |
// MVID: 52DF839B-9B18-40C2-9E30-2E3827E07665 | |
// Assembly location: C:\code\AsyncAwaitTest\AsyncAwaitTest\bin\Debug\netcoreapp3.1\AsyncAwaitTest.dll | |
// Compiler-generated code is shown | |
using System; | |
using System.Diagnostics; | |
using System.IO; |
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; | |
namespace ClassVsStructDemo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
DemoStruct struct1 = new DemoStruct(); | |
struct1.x = 4; |
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
Hey everyone, today I'd like to go over the differences between classes and structs in C# | |
We'll start with how their memory is allocated. | |
Whenever you see a struct variable, the memory for that struct will be stored in the same location as the variable. | |
So if you have a struct variable in a function, the memory for that struct will be stored within that function's stack frame. | |
If you have an array of structs, the structs' memory will be stored within the array itself. |
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; | |
//https://docs.unity3d.com/ScriptReference/AddComponentMenu.html | |
[AddComponentMenu("Demo/Script To Demo Unity Attributes")] | |
[RequireComponent(typeof(Rigidbody))] | |
[HelpURL("https://www.google.com/search?q=unity+attributes")] | |
[SelectionBase] | |
public class UnityAttrbuteDemo : MonoBehaviour | |
{ | |
[Header("Serialization")] |
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
// https://forum.unity.com/threads/clear-old-texture-references-from-materials.318769/ | |
#define UPDATING_FLOAT_TO_INT | |
#if UNITY_EDITOR | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEditor; | |
public class MaterialPropertyCleaner : EditorWindow { | |
private const float REMOVE_BUTTON_WIDTH = 60; |