Skip to content

Instantly share code, notes, and snippets.

View Seneral's full-sized avatar

Seneral Seneral

View GitHub Profile
@Seneral
Seneral / ConvertSerializationVersion.cs
Last active December 2, 2017 23:03
Script to convert files serialized in 5.5 to previous unity versions based on the text format. 1. Enable force text serialization in ProjectSettings/Editor 2. Right click on the asset in the version it was serialized in and select the target version. 3. Move the created file with the _Converted suffix into the target project.
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
public static class ConvertSerializationVersion
{
private static Regex objectIDSearch = new Regex("--- !u!(?:[0-9]{1,5}) &([0-9]*)");
@Seneral
Seneral / EditorLoadingControl.cs
Last active November 21, 2018 20:29
Extended editor callbacks for entering/leaving playmode and new scenes in Unity
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
#if UNITY_5_3_OR_NEWER || UNITY_5_3
using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;
#endif
using System;
@Seneral
Seneral / SerializableAction.cs
Last active July 7, 2021 14:01
Fully capable SerializableAction for Unity. Supports targets of both UnityEngine.Object and System.Object and one-layer serialization of unserializable types. Supports static and generic methods and classes; Supports most anonymous actions, fully capable of using the context. Support: forum.unity3d.com/threads/406299; Check for updates: https://…
namespace SerializableActionHelper
{
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Reflection;
@Seneral
Seneral / TerrainMeshVisualizer.cs
Last active May 23, 2022 03:50
Fast and simple way to visualize terrain heightmaps in Unity 3D - simple offset surface shader included - to use, assign material properties per script and use TerrainMeshVisualizer.DrawVisualization to draw a temporary visualization
using UnityEngine;
[System.Serializable]
public class TerrainMeshVisualizer
{
public Material material;
private const int tileRes = 128;
private Mesh _tileMesh;
@Seneral
Seneral / 0 Warning.md
Last active August 7, 2022 16:57
DOESN'T WORK ANYMORE - for workaround see https://gist.github.com/p3g4asus/597050997e01f8fd1fcf473fe6545a4fModified VLC YouTube playlist parsing script to support playlists with more than 200 videos. Verified it works with 1000+ videos, no duplicates and all included (minus deleted videos). Official version claims to support 100+, but actually o…
@Seneral
Seneral / RTEditorGUI.cs
Last active October 3, 2022 07:42
Extended editor GUI controls for runtime usage in Unity. Includes runtime-compatible editor control ports, new controls and fields, advanced texture drawing utilities, general texture utilities and efficient clipped bezier drawing. Bezier drawing needs line texture www.dropbox.com/s/2qn3q3nwhny17ok and (optional) GUIScaleUtility gist
using UnityEngine;
using System;
using System.Globalization;
using System.Linq;
using System.Collections.Generic;
using Object = UnityEngine.Object;
namespace NodeEditorFramework.Utilities
{
@Seneral
Seneral / PoseManager.cs
Last active November 3, 2022 07:01
Allows to save, export, import and restore a SkinnedMeshRenderer's bone transformation state (aka pose). This includes resetting to the initial model pose. Put PoseManagerEditor.cs in an editor folder.
using UnityEngine;
using System;
using System.Linq;
using System.Collections.Generic;
[ExecuteInEditMode]
public class PoseManager : MonoBehaviour
{
public SkinnedMeshRenderer skinnedRenderer;
public List<RigPose> poses = new List<RigPose> ();
@Seneral
Seneral / GUIScaleUtility.cs
Last active May 5, 2023 05:46
Advanced GUI scaling for Unity. Fixes problems with unscaled clipping rect using reflection. Allows for custom zoom positions other than (0,0). Need all elements to offset by a specified value to account for zoom position and scale though. Example of use is my open source Node Editor Framework
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Reflection;
namespace NodeEditorFramework.Utilities
{
public static class GUIScaleUtility
@Seneral
Seneral / Lock.hpp
Last active November 11, 2023 17:23
Standalone Folly Synchronized - With std::shared_mutex (no upgrade) - see revision for changes from original
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software