2022-08-01から1ヶ月間の記事一覧
参考サイト様
ソースコード using System; using System.Collections.Generic; using System.IO; using System.Reflection; using UnityEditor; using UnityEditor.PackageManager.UI; using UnityEditorInternal; using UnityEngine.UIElements; using PackageInfo = Uni…
概要 Preferences の「Editor > Color Scheme > General」の 「Editor > Selection background」の「Background」の色を変更する
概要 「システム環境設定 > セキュリティとプライバシー > 画面収録」で 「Rider.app」のチェックを外したら正常に動作するようになった
概要 https://zenn.dev/topics/unity/feed 上記の URL を RSS リーダに追加する
ソースコード using JetBrains.Annotations; using UnityEditor; using UnityEditor.DeviceSimulation; using UnityEngine.UIElements; namespace Kogane.Internal { [UsedImplicitly] internal sealed class DeviceSimulatorMuteAudioPlugin : DeviceSimula…
概要 using UnityEditor; using UnityEngine; public sealed class Example : EditorWindow { private bool m_isInitialized; private string m_name; [MenuItem( "Tools/Hoge" )] public static void Open() { GetWindow<Example>(); } private void OnGUI() { GUI.S</example>…
概要 var text = Regex.Replace( text, "<.*?>", string.Empty );
概要 using UnityEditor; public sealed class Example : EditorWindow { private void Update() { Repaint(); } } Update で Repaint を呼び出すと OnGUI が毎フレーム更新される
ソースコード using UnityEngine; namespace Kogane { /// <summary> /// Transform の初期値を保持しておくためのコンポーネント /// </summary> [DisallowMultipleComponent] [DefaultExecutionOrder( -1000 )] public sealed class DefaultTransform : MonoBehaviour { //===…
概要 var root = new VisualElement(); root.style.flexDirection = FlexDirection.Row; VisualElement の style.flexDirection に FlexDirection.Row を指定する これだけだと要素が左に表示されてしまう var root = new VisualElement(); root.style.flexD…
ソースコード using System.Linq; using UnityEditor; using UnityEngine; internal sealed class Example : AssetPostprocessor { private const string PATH = "ProjectSettings/EditorBuildSettings.asset"; private static void OnPostprocessAllAssets …
概要 using System.Collections.Generic; namespace Kogane { public static class SequenceJoinTupleExtensionMethods { public static (T1, T2)[] JoinTuple<T1, T2>( this T1[] self, T2[] other ) { var count = self.Length; var result = new (T1, T2)[ count </t1,>…
概要 using System.Collections.Generic; using System.Linq; namespace Kogane { public static class EnumerableExtensionMethods { public static IEnumerable<T> PrependIf<T> ( this IEnumerable<T> self, bool conditional, T element ) { return !conditional </t></t></t>…
概要 using System.Text.Json; using UnityEngine; public enum CharacterType { NONE, PLAYER, ENEMY, } public class Example : MonoBehaviour { private void Start() { var data = new { characterType = CharacterType.PLAYER }; Debug.Log( JsonSerial…
概要 [ResetStatic] public static bool IsInitialized { get; private set; } Cecil Attributes の Reset Static をプロパティに対して付与したら InvalidProgramException: Invalid IL code in XXXX:CecilAttributesGenerated_ResetStatics (): IL_0001: c…
概要 [ResetStatic] private static float? m_value; null 許容値型のフィールドに Reset Static を使ったら Unity 再生時にエディタがクラッシュする現象に遭遇した null 許容値型のフィールドに Reset Static を使わないようにしたらクラッシュしなくなっ…
ソースコード using UnityEngine; namespace Kogane { /// <summary> /// GetComponent の結果をキャッシュしておくためのクラス /// </summary> public sealed class ComponentCache<T> { private T m_cache; private bool m_isCached; public T Get( GameObject gameObject ) { /</t>…
ソースコード using UnityEditor; using UnityEngine; using UnityEngine.UI; namespace Kogane.Internal { internal static class AspectRatioFitterMenuItem { [MenuItem( "CONTEXT/AspectRatioFitter/Set Default Aspect Ratio" )] private static void S…
ソースコード @echo off set /P ANSWER="キャッシュを削除しますか (Y/N)?" if /i {%ANSWER%}=={y} (goto :yes) if /i {%ANSWER%}=={yes} (goto :yes) exit :yes rd /s /q Library\ rd /s /q Logs\ rd /s /q obj\ rd /s /q Temp\ del *.csproj del *.sln ec…
ソースコード using System; using System.Linq; using System.Reflection; using UnityEditor; using UnityEditor.DeviceSimulation; using UnityEngine; namespace Kogane { [InitializeOnLoad] public static class DeviceSimulatorDeviceChecker { priva…
ソースコード using Packages.Rider.Editor; using UnityEditor; namespace Kogane.Internal { internal static class JetBrainsRiderRegenerateProjectFiles { [MenuItem( "Kogane/Rider/Regenerate project files" )] private static void SyncSolution() …
概要 The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered: Unity で作業していたら上記の警告が出力されるようになった Unity を再起動したら出なくなった
はじめに 「Debugging」を Unity プロジェクトに導入することで Scene ウィンドウに簡単にデバッグ表示できるようになります 使用例 using UnityEngine; using Vertx.Debugging; public class Example : MonoBehaviour { private void Update() { DebugUtils…
概要 var button = new Button { text = "ボタン" }; button.style.width = 10; style.width を使用する
ソースコード using System.Reflection; using UnityEditor; using UnityEditor.DeviceSimulation; using UnityEngine; [InitializeOnLoad] public static class Example { static Example() { // 1 フレーム遅らせないと deviceSimulatorMain が null にな…
概要 Project Settings を開いて左メニューで「Package Manager」を選択して 「Show Dependencies」をオンにすると Package Manager でパッケージの依存関係を確認できるようになる
概要 Unity 2022 から PolygonCollider2D などで Use Delaunay Mesh をオンにすると ポリゴン数を減らせるようになった (左がオフ、右がオン) 参考サイト様
概要 using UnityEngine; public class Example : MonoBehaviour { public int[] m_intArray; } int や float の配列は Inspector で Ctrl + D で要素を複製できる string や参照型は Ctrl + D を押しても何も起きない
検証内容 30,000 個のスプライトをシーンに配置 スプライトの Custom Outline を設定した場合としなかった場合の FPS を比較 検証環境 Unity 2021.3.1f1 Custom Outline を設定した場合 36 ~ 39 FPS Custom Outline を設定しなかった場合 38 ~ 42 FPS 結論 …