Skip to content

Instantly share code, notes, and snippets.

View DmitriyYukhanov's full-sized avatar
🦄
Making stuff =)

Dmitriy Yukhanov DmitriyYukhanov

🦄
Making stuff =)
View GitHub Profile
@DmitriyYukhanov
DmitriyYukhanov / DropdownSelectionCanceledExample.cs
Last active November 23, 2021 10:07
Listen to AdvancedDropdown selection cancellation in Unity 2022.1 using Reflection (actual as per 2022.1.0a15)
namespace CodeStage.Gists.Editor
{
using System;
using System.Reflection;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
public class DropdownSelectionCanceledExample : AdvancedDropdown
{
//...
@DmitriyYukhanov
DmitriyYukhanov / ObjectTools.cs
Created March 21, 2017 11:18
Updated code to get a Unity object id.
#define UNITY_5_PLUS
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
#undef UNITY_5_PLUS
#endif
using UnityEngine;
using System.Reflection;
using UnityEditor;
namespace CodeStage.Maintainer.Tools
@DmitriyYukhanov
DmitriyYukhanov / dummy.cs
Created January 4, 2017 12:21
How to select asset in Project Browser without loading Asset.
// use to select asset at the Project Browser when you know path and asset
// has no objects inside, e.g. AssetDatabase.LoadMainAssetAtPath() returns null
// path - relative to Project folder, e.g. Assets/StrangeFile.asset
public static void SelectNonObjectFile(string path)
{
string guid = AssetDatabase.AssetPathToGUID(path);
// in perfect world, all reflection should be cached (including method delegate)
Type assetDatabaseType = typeof(AssetDatabase);
MethodInfo mi = assetDatabaseType.GetMethod("GetInstanceIDFromGUID", BindingFlags.NonPublic | BindingFlags.Static);
@DmitriyYukhanov
DmitriyYukhanov / WaitForSecondsUnscaled.cs
Last active January 5, 2017 22:40
Cacheable WaitForSecondsUnscaled CustomYieldInstruction example
/*
Copyright (c) 2016 Dmitriy Yukhanov
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
#define UNITY_5_PLUS
#if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
#undef UNITY_5_PLUS
#endif
using UnityEngine;
using System.Reflection;
using UnityEditor;
namespace CodeStage.Maintainer.Tools