Skip to content

Instantly share code, notes, and snippets.

View dimmduh's full-sized avatar
🎮
Learning Unity

Dmitrii Dukhnich dimmduh

🎮
Learning Unity
View GitHub Profile
@Dreezn
Dreezn / ClipStartEndInMixer.cs
Last active August 12, 2024 07:36
Getting the Clip Start End Times through to the mixer
/* 1 - Overriding CreateTrackMixer in the CustomTransformationTrack class,
getting the start & end times for each clip, and passing them to the custom clip class. */
//[Omitted...]
public class CustomTransformationTrack : TrackAsset
{
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
foreach (var clip in GetClips())
{
@LotteMakesStuff
LotteMakesStuff / 1.md
Last active January 2, 2025 21:54
UPM: How to make a custom package

UPM: How to make a custom package So, Unity has this shiny new package manager, and you have code you want to share between projects - wouldn't it be great if we could bundle up our shared code and plug it into all the projects that need it? Let's figure out how to make our own Package!


Todo

  • Modify the project manifest
  • Make a package manifest
  • Package the manifest up with some test code
  • Try it out in Unity!

@nicoplv
nicoplv / DebugPanel.cs
Created March 13, 2018 10:22
Debug Panel for Unity - To debug your variables more easily
using System.Collections.Generic;
using UnityEngine;
namespace SmartUnity.Debugs
{
public class DebugPanel
{
#region Variables
private static DebugPanel debugPanel;
@LotteMakesStuff
LotteMakesStuff / PackageManagerExtentionExample.cs
Last active July 23, 2024 03:25
As of v1.9.3, Unity has added a simple extention API to the PackageManager UI. This small example shows you how to implment it and add a new window to the package manager. Note: you will need to change to the Staging package repository as time of writing. This code needs to go in an Editor folder
using System.Linq;
using UnityEditor;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
using UnityEngine.Experimental.UIElements.StyleEnums;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
[InitializeOnLoad]
public class PackageManagerExtentionExample : IPackageManagerExtension
@jeffvella
jeffvella / UnityDrawStringDebugText
Created August 2, 2018 13:34
Drawing Debug text with background in Unity
public static void DrawString(string text, Vector3 worldPos, Color? textColor = null, Color? backColor = null)
{
UnityEditor.Handles.BeginGUI();
var restoreTextColor = GUI.color;
var restoreBackColor = GUI.backgroundColor;
GUI.color = textColor ?? Color.white;
GUI.backgroundColor = backColor ?? Color.black;
var view = UnityEditor.SceneView.currentDrawingSceneView;
@vildninja
vildninja / RemoveMissingScriptsRecursively.cs
Created March 25, 2019 10:06
Remove missing MonoBehaviour script components in Unity 2019.1 including visiting prefafab assets.
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
public static class FindMissingScriptsRecursively
{
[MenuItem("Auto/Remove Missing Scripts Recursively Visit Prefabs")]
private static void FindAndRemoveMissingInSelected()
{
// EditorUtility.CollectDeepHierarchy does not include inactive children
using System.Collections;
using UnityEngine;
public class MacosKeychain
{
public static string GetKeychainPassword(string accountName,string serviceName)
{
var value = ShellHelper.Bash($"security find-generic-password -a {accountName} -s {serviceName} -w -g");
return value.TrimEnd( '\r', '\n' );
@phosphoer
phosphoer / ControllerIconMapDefinition.cs
Last active June 10, 2024 23:20
Rewired Glyph Mappings
using UnityEngine;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "new-controller-icon-mapping", menuName = "Controller Icon Mapping")]
public class ControllerIconMapDefinition : ScriptableObject
{
[SerializeField]
private InputIconMapDefinition gamepadMap = null;
[SerializeField]
@edwardrowe
edwardrowe / BuildToolExample.cs
Last active March 22, 2021 16:12
An example of a Build Tool, used to accompany my blog post on Versioning with git in Unity.
/* MIT License
Copyright (c) 2016 RedBlueGames
*/
using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Reporting;
public class BuildToolExample : MonoBehaviour
{
@kraj0t
kraj0t / RebasePrefab.cs
Last active November 1, 2022 02:50
RebasePrefab - Unity editor tool to convert a prefab into a variant of a new empty prefab
/*
* @brief Editor menu item for turning a prefab into a variant of a new empty prefab.
*
* @usage Access from the MenuItem defined in the code. As right-click or from the menu bar.
*
* @author Aurelio Provedo
* Contact: [email protected]
*
*/