Skip to content

Instantly share code, notes, and snippets.

View CodeSmile-0000011110110111's full-sized avatar

CodeSmile CodeSmile-0000011110110111

View GitHub Profile
@CodeSmile-0000011110110111
CodeSmile-0000011110110111 / EditorUndoRedoExample.cs
Created March 5, 2023 11:20
Editor On*GUI undo/redo example
protected virtual void OnSceneGUI()
{
HandlesTest testObject = (HandlesTest)target;
// begin monitoring for GUI changes
EditorGUI.BeginChangeCheck();
// do whatever GUI stuff that lets user change something on the testObject
var newPos = Handles.PositionHandle(testObject.transform.position, Quaternion.identity);
@CodeSmile-0000011110110111
CodeSmile-0000011110110111 / ExampleEditorSwitchOnEventType.cs
Created March 5, 2023 11:27
On*GUI should only switch on EventType and call methods to reduce code complexity
using CodeSmile.UnityEditor;
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace CodeSmile.Tile.UnityEditor
{
[CustomEditor(typeof(TileWorld))]
public class TileWorldDrawer : Editor
@CodeSmile-0000011110110111
CodeSmile-0000011110110111 / TestCustomBuildProcess.cs
Created March 5, 2023 11:33
Example PreProcessing script for Unity's build process and overriding File-Build command the official way
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace CodeSmile.EditorTests
{
[InitializeOnLoad]
public class TestCustomBuildProcess
@CodeSmile-0000011110110111
CodeSmile-0000011110110111 / FasterTests.cs
Created May 2, 2023 19:13
Speed up Unity TestRunner running tests
// This work is Public Domain (CC0) - "No Rights Reserved"
// License: https://creativecommons.org/publicdomain/zero/1.0/
using System.Reflection;
using UnityEditor;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine;
namespace CodeSmile.Tests.Utilities
{
@CodeSmile-0000011110110111
CodeSmile-0000011110110111 / NestedNativeListSerializationTests.cs
Last active September 11, 2025 03:11
Unity.Serialization for NativeList<UnsafeList<T>> with adapters
// Copyright (C) 2021-2023 Steffen Itterheim
// Refer to included LICENSE file for terms and conditions.
using NUnit.Framework;
using System;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Serialization.Binary;
using UnityEngine;
using CodeSmile.Components.Registry;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace CodeSmile.Components.Pool
{
[DisallowMultipleComponent]