Skip to content

Instantly share code, notes, and snippets.

Feature Record (Limited Support)
Type Reference Type
Mutability Immutable (potentially in future)
Complexity More concise syntax for data-centric classes (limited use in Unity)
Memory Usage Potentially less efficient than structs for small data (Unity context)
Unity Focus Not fully supported yet
Performance Potentially slower than structs, but with benefits (future)
Data Access Reference indirection (slower)
Built-in Functionalities Equality comparison, Hashing (potential benefit)
Feature Class
Type Reference Type
Mutability Mutable
Complexity Can be complex with inheritance and methods
Memory Usage Less efficient for frequently copied large structs
Unity Focus Less common
Performance Slowest
Data Access Reference indirection (slower)
Built-in Functionalities No
Feature Struct
Type Value Type
Mutability Mutable
Complexity Simpler, for data grouping
Memory Usage Efficient for small data
Unity Focus Preferred for performance-critical data
Performance Generally fastest for small data
Data Access Direct access
Built-in Functionalities No
@irfanbaysal
irfanbaysal / Class vs Struct vs Record.csv
Created April 3, 2024 07:50
Fundamentals for Creating Data Structure
Feature Struct Class Record (Limited Support)
Type Value Type Reference Type Reference Type
Mutability Mutable Mutable Immutable (potentially in future)
Complexity Simpler, for data grouping Can be complex with inheritance and methods More concise syntax for data-centric classes (limited use in Unity)
Memory Usage Efficient for small data Less efficient for frequently copied large structs Potentially less efficient than structs for small data (Unity context)
Unity Focus Preferred for performance-critical data Less common Not fully supported yet
Performance Generally fastest for small data Slowest Potentially slower than structs, but with benefits (future)
Data Access Direct access Reference indirection (slower) Reference indirection (slower)
Built-in Functionalities No No Equality comparison, Hashing (potential benefit)
@irfanbaysal
irfanbaysal / Creating Custom Converter
Created January 15, 2024 18:28
Json Examples Part 3
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace JsonDeserializeExample.Scripts
{
public enum VehicleType
{
@irfanbaysal
irfanbaysal / Json Examples Formatting
Created January 12, 2024 10:26
Json Examples Part 2
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace JsonDeserializeExample.Scripts
{
public enum VehicleType
{
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;
namespace JsonDeserializeExample.Scripts
{
public enum VehicleType
{
Default,
@irfanbaysal
irfanbaysal / BitMask Tutorial Codeblock
Created December 14, 2023 11:05
BitMask Tutorial Codeblock
using System;
//using Sirenix.OdinInspector;
using UnityEngine;
[Flags]
public enum SoldierType
{
None = 0,
Private = 1,
Corporal = 2,
@irfanbaysal
irfanbaysal / Preset Editor
Last active September 4, 2023 07:16
Preset Editor
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEditor.Presets;
using UnityEngine;
using UnityEngine.Serialization;
namespace PresetEditor
@irfanbaysal
irfanbaysal / Play Mode Scene
Created April 15, 2023 09:42
Play Mode Scene
public class StartSceneWindow : EditorWindow
{
private const string ScenePath = "Assets/Core/Scenes/MainScene.unity";
private void OnGUI()
{
EditorSceneManager.playModeStartScene = (SceneAsset)EditorGUILayout.ObjectField(new GUIContent("Start Scene"),
EditorSceneManager.playModeStartScene, typeof(SceneAsset),false);
if (GUILayout.Button("Set as Start Scene"))
SetPlayModeStartScene(ScenePath);