Skip to content

Instantly share code, notes, and snippets.

View unity3d-kr's full-sized avatar

J1.Jeong unity3d-kr

View GitHub Profile
// Difference between Unity Editor IconContent and TrIconContent.
// IconContent hash based on name. So, it is used when looking for an image of an icon.
// However, TrIconContent hash based on name and tooltip.
// So, when you sets the tooltip, TrIconContent must be used.
public sealed partial class EditorGUIUtility : GUIUtility
{
static Hashtable s_IconGUIContents = new Hashtable();
public static GUIContent TrIconContent(string iconName, string tooltip)
{
@unity3d-kr
unity3d-kr / csharpui.md
Last active June 5, 2024 03:04
C# UI Platform
@unity3d-kr
unity3d-kr / CustomModelImporterInspector.cs
Created February 4, 2024 02:49
Search and Extract Materials... in Model Importer (Unity 2022)
using System;
using System.IO;
using System.Reflection;
using System.Linq;
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using Object = UnityEngine.Object;
namespace UnityEditor
@unity3d-kr
unity3d-kr / hlsl.xml
Created August 10, 2023 09:57
HLSL, Unity Shader vs2019-dark style for Notepad++
<NotepadPlus>
<UserLang name="HLSL" ext="cginc shader vs fs hlsl ush" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="yes" Keywords5="no" Keywords6="yes" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2">0x</Keywords>
@unity3d-kr
unity3d-kr / PrefabApplyUnsafe.cs
Last active April 29, 2021 09:05
Prefab Appy in Play mode for Unity 2019
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
private static string AssetPrefabsRoot = "Assets";
[MenuItem("GameObject/Prefab/Apply (Unsafe)", false, -2)]
@unity3d-kr
unity3d-kr / GetIcon.cs
Last active November 20, 2020 02:01
Unity Icon by file path
Dictionary<string, GUIContent> iconMap = new Dictionary<string, GUIContent>();
GUIContent GetIcon(string path)
{
string ext = Path.GetExtension(path).ToLower();
if (iconMap.ContainsKey(ext))
return iconMap[ext];
GUIContent icon = null;
try
{
@unity3d-kr
unity3d-kr / AraTrailEditor.cs
Last active November 10, 2020 04:12
Draw Material Editor in Inspector
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;
[CustomEditor(typeof(AraTrail))]
[CanEditMultipleObjects]
internal class AraTrailEditor : Editor
{
@unity3d-kr
unity3d-kr / ObjectFieldEx.cs
Last active November 13, 2023 10:41
EditorGUI.ObjectField without object picker
internal static class ObjectFieldEx
{
private static readonly int s_ObjectFieldHash = "s_ObjectFieldHash".GetHashCode();
internal const float kSingleLineHeight = 18f;
private const float kIndentPerLevel = 15;
public static Object ObjectField(Object obj, Type objType, params GUILayoutOption[] options)
{
Rect r = EditorGUILayout.GetControlRect(true, kSingleLineHeight, options);
return ObjectField(r, obj, objType);
@unity3d-kr
unity3d-kr / GizmosEx.cs
Last active October 27, 2020 03:48
DrawWireDist() looks like Gizmo
static void DrawWireDist(Vector3 center, float radius)
{
#if UNITY_EDITOR
var oldColor = UnityEditor.Handles.color;
var oldZTest = UnityEditor.Handles.zTest;
UnityEditor.Handles.zTest = UnityEngine.Rendering.CompareFunction.Greater;
UnityEditor.Handles.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, 0.25f);
UnityEditor.Handles.DrawWireDisc(center, Vector3.up, radius);
UnityEditor.Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
@unity3d-kr
unity3d-kr / RepaintInspector.cs
Last active October 27, 2020 03:47
repaint only specificated inspector
public static void RepaintInspector(System.Type t)
{
Editor[] ed = (Editor[])Resources.FindObjectsOfTypeAll<Editor>();
for (int i = 0; i < ed.Length; i++)
{
if (ed[i].target.GetType() == t)
{
ed[i].Repaint();
return;
}