2022-09-01から1ヶ月間の記事一覧
概要 private static bool IsAsynchronousMethod( MethodInfo methodInfo ) { return IsUniTask( methodInfo.ReturnType ); } private static bool IsUniTask( Type type ) { return type.IsGenericType ? type.GetGenericTypeDefinition() == typeof( UniTa…
概要 private static bool IsUniTask( Type type ) { return type.IsGenericType ? type.GetGenericTypeDefinition() == typeof( UniTask<> ) : type == typeof( UniTask ) ; }
ソースコード using UnityEditor; using UnityEditorInternal; using UnityEngine; namespace Kogane.Internal { internal static class TransformCopyComponentPasteComponentValues { [MenuItem( "CONTEXT/Transform/Copy Component" )] public static voi…
概要 C# 9.0 までは引数なしコンストラクタを定義できないため 構造体のフィールドに初期値を設定できない 代替案としてフィールドを nullable にして プロパティの getter でフィールドが null なら初期値を設定する方法がある using UnityEngine; public s…
概要 using UnityEngine; public class Example : MonoBehaviour { private void Update() { // GC Alloc が 31.2 KB for ( var i = 0; i < 1000; i++ ) { var strings = new string[ 0 ]; } } } using System; using UnityEngine; public class Example : M…
ソースコード using System.Diagnostics; using System.IO; using UnityEditor; namespace Kogane.Internal { internal static class ShowProjectInExplorer { #if UNITY_EDITOR_WIN [MenuItem( "File/Show Project in Explorer" )] #else [MenuItem( "File/…
概要 using System.Text.RegularExpressions; namespace Kogane { public static class ResourcesPath { private static readonly Regex REGEX = new( @"^.*Resources/(.*)\..*" ); public static string ToResourcesPath( string assetPath ) { return REGE…
ソースコード using UnityEditor; using UnityEngine; namespace Kogane.Internal { [InitializeOnLoad] internal static class ScriptableObjectCreatorOnInspector { static ScriptableObjectCreatorOnInspector() { Editor.finishedDefaultHeaderGUI -= O…
概要 End Cap Vertices を設定する
概要 Debug.Log( string.Join( "\n", EditorSettings.projectGenerationUserExtensions ) );
ソースコード using UnityEditor; using UnityEngine; namespace Kogane.Internal { internal static class RenameGameObjectMenuItem { [MenuItem( "CONTEXT/Component/Rename Game Object" )] private static void Rename( MenuCommand menuCommand ) { va…
概要 using Needle.Deeplink; using UnityEditor; using UnityEngine; internal static class Example { [DeepLink( RegexFilter = @"com.unity3d.kharma:open-asset\/(.*)" )] private static bool OpenAsset( string assetName ) { Debug.Log( assetName )…
概要 using Needle.Deeplink; using UnityEditor; using UnityEngine; internal static class Example { [DeepLink( RegexFilter = @"com.unity3d.kharma:ping-game-object\/(.*)" )] private static bool PingGameObject( string gameObjectName ) { Debug.…
概要 using Needle.Deeplink; using UnityEditor; using UnityEngine; internal static class Example { [DeepLink( RegexFilter = @"com.unity3d.kharma:ping-asset\/(.*)" )] private static bool PingAsset( string assetPath ) { Debug.Log( assetPath )…
概要 using Needle.Deeplink; using UnityEditor; using UnityEngine; internal static class Example { [DeepLink( RegexFilter = @"com.unity3d.kharma:execute-menu-item\/(.*)" )] private static bool ExecuteMenuItem( string menuItemPath ) { Debug.…
概要 using UnityEditor; using UnityEditor.IMGUI.Controls; public class Example : EditorWindow { private SearchField m_searchField; private string m_text; [MenuItem( "Tools/Hoge" )] private static void Open() { GetWindow<Example>(); } private void O</example>…
概要 [InitializeOnLoadMethod] private static void Hoge() { CompilationPipeline.compilationFinished += _ => { Debug.Log( "ピカチュウ" ); // 呼ばれる EditorApplication.delayCall += () => { Debug.Log( "カイリュー" ); // 呼ばれない }; }; } Ass…
概要 Assertion failed on expression: 'IsInSyncWithParentSerializedObject()' UnityEditor.RetainedMode:UpdateSchedulers () Scene Template の Thumbnail の Preview に画像を設定すると Project ウィンドウで Scene Template を選択するたびに 上記の…
概要 using UnityEditor; using UnityEditor.SceneTemplate; using UnityEngine; public static class Example { [MenuItem( "Tools/Hoge" )] private static void Hoge() { var sceneTemplateAssetPath = "【.scenetemplate のパス】"; var scenePath = "【…
ソースコード using System.IO; using UnityEditor; using UnityEditor.PackageManager; using UnityEditorInternal; using UnityEngine; namespace Kogane.Internal { [InitializeOnLoad] internal static class PackageEmbedder { static PackageEmbedder(…
ソースコード using UnityEditor; using UnityEngine; namespace Kogane.Internal { [InitializeOnLoad] internal static class MuteAudioMenuItem { private const string MENU_ITEM_NAME = "Kogane/Mute Audio"; static MuteAudioMenuItem() { EditorAppli…
概要 Unity エディタだと正常に動作するが iOS ビルドだと 「The referenced script on this Behaviour (XXXX) is missing!」が発生する現象に遭遇した Library フォルダを削除してからクリーンビルドしたら解決した
ソースコード using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; namespace Kogane.Internal { [InitializeOnLoad] internal static class InspectorHeaderGUI { static InspectorHeaderGUI() { Editor.finishedDefaultHe…