jp.keijiro.klutter-tools 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/CubeLutImporter.cs +63 -0
- package/Editor/CubeLutImporter.cs.meta +11 -0
- package/Editor/FpsCapperSystem.cs +56 -0
- package/Editor/FpsCapperSystem.cs.meta +2 -0
- package/Editor/KlutterTools.Editor.asmdef +22 -0
- package/Editor/KlutterTools.Editor.asmdef.meta +7 -0
- package/Editor/PlayerLoopHelper.cs +34 -0
- package/Editor/PlayerLoopHelper.cs.meta +2 -0
- package/Editor/PreferencesProvider.cs +83 -0
- package/Editor/PreferencesProvider.cs.meta +2 -0
- package/Editor/VfxGraphZoomStepModifier.cs +43 -0
- package/Editor/VfxGraphZoomStepModifier.cs.meta +2 -0
- package/Editor.meta +8 -0
- package/LICENSE +24 -0
- package/LICENSE.meta +7 -0
- package/README.md +43 -0
- package/README.md.meta +7 -0
- package/package.json +14 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using UnityEditor.AssetImporters;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace Klak.KlutterTools {
|
|
8
|
+
|
|
9
|
+
#if !KLUTTER_TOOLS_HAS_HDRP
|
|
10
|
+
|
|
11
|
+
[ScriptedImporter(0, "cube")]
|
|
12
|
+
class CubeLutImporter : ScriptedImporter
|
|
13
|
+
{
|
|
14
|
+
#region ScriptedImporter implementation
|
|
15
|
+
|
|
16
|
+
public override void OnImportAsset(AssetImportContext ctx)
|
|
17
|
+
{
|
|
18
|
+
var (size, table) = ParseCubeFile(ctx.assetPath);
|
|
19
|
+
|
|
20
|
+
var tex = new Texture3D(size, size, size, TextureFormat.RGBAHalf, false);
|
|
21
|
+
tex.wrapMode = TextureWrapMode.Clamp;
|
|
22
|
+
tex.anisoLevel = 0;
|
|
23
|
+
tex.SetPixels(table);
|
|
24
|
+
tex.Apply();
|
|
25
|
+
|
|
26
|
+
ctx.AddObjectToAsset("3D Lookup Texture", tex);
|
|
27
|
+
ctx.SetMainObject(tex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#endregion
|
|
31
|
+
|
|
32
|
+
#region Parser implementation
|
|
33
|
+
|
|
34
|
+
static bool CheckIfNumber(string word)
|
|
35
|
+
=> '0' <= word[0] && word[0] <= '9';
|
|
36
|
+
|
|
37
|
+
static Color ParseColor(ReadOnlySpan<string> words)
|
|
38
|
+
=> new Color(float.Parse(words[0]),
|
|
39
|
+
float.Parse(words[1]),
|
|
40
|
+
float.Parse(words[2]));
|
|
41
|
+
|
|
42
|
+
(int size, Color[] table) ParseCubeFile(string filePath)
|
|
43
|
+
{
|
|
44
|
+
var (size, table) = (0, new List<Color>());
|
|
45
|
+
foreach (var line in File.ReadLines(filePath))
|
|
46
|
+
{
|
|
47
|
+
var words = line.Split();
|
|
48
|
+
if (words.Length == 0 || words[0].Length == 0)
|
|
49
|
+
continue;
|
|
50
|
+
else if (words[0] == "LUT_3D_SIZE")
|
|
51
|
+
size = int.Parse(words[1]);
|
|
52
|
+
else if (CheckIfNumber(words[0]))
|
|
53
|
+
table.Add(ParseColor(words));
|
|
54
|
+
}
|
|
55
|
+
return (size, table.ToArray());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#endregion
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#endif
|
|
62
|
+
|
|
63
|
+
} // namespace Klak.KlutterTools
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
using System.Threading;
|
|
4
|
+
|
|
5
|
+
namespace Klak.KlutterTools {
|
|
6
|
+
|
|
7
|
+
// FPS Capper player loop sub system
|
|
8
|
+
[InitializeOnLoad]
|
|
9
|
+
sealed class FpsCapperSystem
|
|
10
|
+
{
|
|
11
|
+
// Synchronization object
|
|
12
|
+
static AutoResetEvent _sync;
|
|
13
|
+
|
|
14
|
+
// Interval in milliseconds
|
|
15
|
+
static int IntervalMsec;
|
|
16
|
+
|
|
17
|
+
// Interval thread function
|
|
18
|
+
static void IntervalThread()
|
|
19
|
+
{
|
|
20
|
+
for (_sync = new AutoResetEvent(true); true;)
|
|
21
|
+
{
|
|
22
|
+
Thread.Sleep(Mathf.Max(1, IntervalMsec));
|
|
23
|
+
_sync.Set();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Custom system update function
|
|
28
|
+
static void UpdateSystem()
|
|
29
|
+
{
|
|
30
|
+
// Property update
|
|
31
|
+
IntervalMsec = 1000 / Mathf.Max(5, Preferences.FpsCapperFrameRate);
|
|
32
|
+
|
|
33
|
+
// Rejection cases
|
|
34
|
+
if (_sync == null) return;
|
|
35
|
+
if (!Preferences.FpsCapperEnable) return;
|
|
36
|
+
if (Preferences.FpsCapperFrameRate < 1) return;
|
|
37
|
+
if (Time.captureDeltaTime != 0) return;
|
|
38
|
+
|
|
39
|
+
// Synchronization with the interval thread
|
|
40
|
+
_sync.WaitOne();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Static constructor
|
|
44
|
+
static FpsCapperSystem()
|
|
45
|
+
{
|
|
46
|
+
// Interval thread launch
|
|
47
|
+
new Thread(IntervalThread).Start();
|
|
48
|
+
|
|
49
|
+
// Player loop sub system installation
|
|
50
|
+
PlayerLoopHelper.AddToSubSystem
|
|
51
|
+
<UnityEngine.PlayerLoop.EarlyUpdate, FpsCapperSystem>
|
|
52
|
+
(UpdateSystem);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} // namespace Klak.KlutterTools
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "KlutterTools.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [],
|
|
5
|
+
"includePlatforms": [
|
|
6
|
+
"Editor"
|
|
7
|
+
],
|
|
8
|
+
"excludePlatforms": [],
|
|
9
|
+
"allowUnsafeCode": false,
|
|
10
|
+
"overrideReferences": false,
|
|
11
|
+
"precompiledReferences": [],
|
|
12
|
+
"autoReferenced": true,
|
|
13
|
+
"defineConstraints": [],
|
|
14
|
+
"versionDefines": [
|
|
15
|
+
{
|
|
16
|
+
"name": "com.unity.render-pipelines.high-definition",
|
|
17
|
+
"expression": "1.0.0",
|
|
18
|
+
"define": "KLUTTER_TOOLS_HAS_HDRP"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"noEngineReferences": false
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine.LowLevel;
|
|
3
|
+
|
|
4
|
+
namespace Klak.KlutterTools {
|
|
5
|
+
|
|
6
|
+
public static class PlayerLoopHelper
|
|
7
|
+
{
|
|
8
|
+
public static void AddToSubSystem<P, T>
|
|
9
|
+
(PlayerLoopSystem.UpdateFunction updateFunc)
|
|
10
|
+
{
|
|
11
|
+
var loop = PlayerLoop.GetCurrentPlayerLoop();
|
|
12
|
+
|
|
13
|
+
for (var i = 0; i < loop.subSystemList.Length; i++)
|
|
14
|
+
{
|
|
15
|
+
ref var subsys = ref loop.subSystemList[i];
|
|
16
|
+
if (subsys.type != typeof(P)) continue;
|
|
17
|
+
|
|
18
|
+
var target = new PlayerLoopSystem
|
|
19
|
+
{ type = typeof(T), updateDelegate = updateFunc };
|
|
20
|
+
|
|
21
|
+
var len = subsys.subSystemList.Length;
|
|
22
|
+
Array.Resize(ref subsys.subSystemList, len + 1);
|
|
23
|
+
subsys.subSystemList[len] = target;
|
|
24
|
+
|
|
25
|
+
PlayerLoop.SetPlayerLoop(loop);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw new InvalidOperationException
|
|
30
|
+
($"Can't find player sub system {typeof(P)}");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
} // namespace Klak.KlutterTools
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
using UnityEditor;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Klak.KlutterTools {
|
|
5
|
+
|
|
6
|
+
// Preference accessor
|
|
7
|
+
public static class Preferences
|
|
8
|
+
{
|
|
9
|
+
public static bool FpsCapperEnable
|
|
10
|
+
{ get => EditorPrefs.GetBool(Keys.FpsCapperEnable, false);
|
|
11
|
+
set => EditorPrefs.SetBool(Keys.FpsCapperEnable, value); }
|
|
12
|
+
|
|
13
|
+
public static int FpsCapperFrameRate
|
|
14
|
+
{ get => EditorPrefs.GetInt(Keys.FpsCapperFrameRate, 60);
|
|
15
|
+
set => EditorPrefs.SetInt(Keys.FpsCapperFrameRate, value); }
|
|
16
|
+
|
|
17
|
+
public static float VfxGraphZoomStep
|
|
18
|
+
{ get => EditorPrefs.GetFloat(Keys.VfxGraphZoomStep, 1);
|
|
19
|
+
set => EditorPrefs.SetFloat(Keys.VfxGraphZoomStep, value); }
|
|
20
|
+
|
|
21
|
+
// Preference keys
|
|
22
|
+
static class Keys
|
|
23
|
+
{
|
|
24
|
+
public const string FpsCapperEnable
|
|
25
|
+
= "Klak.KlutterTools.FpsCapper.Enable";
|
|
26
|
+
|
|
27
|
+
public const string FpsCapperFrameRate
|
|
28
|
+
= "Klak.KlutterTools.FpsCapper.FrameRate";
|
|
29
|
+
|
|
30
|
+
public const string VfxGraphZoomStep
|
|
31
|
+
= "Klak.KlutterTools.VfxGraph.ZoomStep";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Preference provider (GUI)
|
|
36
|
+
public sealed class PreferencesProvider : SettingsProvider
|
|
37
|
+
{
|
|
38
|
+
public PreferencesProvider()
|
|
39
|
+
: base("Preferences/Klutter Tools", SettingsScope.User) {}
|
|
40
|
+
|
|
41
|
+
public override void OnGUI(string search)
|
|
42
|
+
{
|
|
43
|
+
var h = EditorGUIUtility.singleLineHeight / 2;
|
|
44
|
+
|
|
45
|
+
GUILayout.BeginHorizontal();
|
|
46
|
+
GUILayout.Space(h);
|
|
47
|
+
GUILayout.BeginVertical();
|
|
48
|
+
GUILayout.Space(h);
|
|
49
|
+
|
|
50
|
+
EditorGUI.BeginChangeCheck();
|
|
51
|
+
|
|
52
|
+
var fc_enable = Preferences.FpsCapperEnable;
|
|
53
|
+
var fc_frameRate = Preferences.FpsCapperFrameRate;
|
|
54
|
+
var vg_zoomStep = Preferences.VfxGraphZoomStep;
|
|
55
|
+
|
|
56
|
+
GUILayout.Label("FPS Capper", EditorStyles.boldLabel);
|
|
57
|
+
fc_enable = EditorGUILayout.Toggle("Enable", fc_enable);
|
|
58
|
+
fc_frameRate = EditorGUILayout.IntField("Target Frame Rate", fc_frameRate);
|
|
59
|
+
|
|
60
|
+
GUILayout.Space(h);
|
|
61
|
+
|
|
62
|
+
GUILayout.Label("VFX Graph", EditorStyles.boldLabel);
|
|
63
|
+
vg_zoomStep = EditorGUILayout.FloatField("Zoom Step Scale", vg_zoomStep);
|
|
64
|
+
|
|
65
|
+
if (EditorGUI.EndChangeCheck())
|
|
66
|
+
{
|
|
67
|
+
Preferences.FpsCapperEnable = fc_enable;
|
|
68
|
+
Preferences.FpsCapperFrameRate = fc_frameRate;
|
|
69
|
+
Preferences.VfxGraphZoomStep = vg_zoomStep;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
GUILayout.EndVertical();
|
|
73
|
+
GUILayout.EndHorizontal();
|
|
74
|
+
|
|
75
|
+
base.OnGUI(search);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[SettingsProvider]
|
|
79
|
+
public static SettingsProvider GetSettingsProvider()
|
|
80
|
+
=> new PreferencesProvider();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} // namespace Klak.KlutterTools
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Reflection;
|
|
3
|
+
using UnityEditor;
|
|
4
|
+
|
|
5
|
+
namespace Klak.KlutterTools {
|
|
6
|
+
|
|
7
|
+
[InitializeOnLoad]
|
|
8
|
+
public static class VfxGraphZoomStepModifier
|
|
9
|
+
{
|
|
10
|
+
static VfxGraphZoomStepModifier()
|
|
11
|
+
=> EditorWindow.windowFocusChanged += OnWindowFocusChanged;
|
|
12
|
+
|
|
13
|
+
public static void OnWindowFocusChanged()
|
|
14
|
+
{
|
|
15
|
+
var target = EditorWindow.focusedWindow;
|
|
16
|
+
|
|
17
|
+
var vfxViewWindowType = Type.GetType
|
|
18
|
+
("UnityEditor.VFX.UI.VFXViewWindow, Unity.VisualEffectGraph.Editor");
|
|
19
|
+
|
|
20
|
+
if (!vfxViewWindowType.IsInstanceOfType(target)) return;
|
|
21
|
+
|
|
22
|
+
var graphViewProperty = vfxViewWindowType.GetProperty
|
|
23
|
+
("graphView",
|
|
24
|
+
BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
|
|
25
|
+
|
|
26
|
+
var graphView = graphViewProperty.GetValue(target);
|
|
27
|
+
if (graphView == null) return;
|
|
28
|
+
|
|
29
|
+
var vfxViewType = graphView.GetType();
|
|
30
|
+
var argTypes = new []
|
|
31
|
+
{ typeof(float), typeof(float), typeof(float), typeof(float) };
|
|
32
|
+
|
|
33
|
+
var setupZoomMethod = vfxViewType.GetMethod
|
|
34
|
+
("SetupZoom",
|
|
35
|
+
BindingFlags.Public | BindingFlags.Instance, null, argTypes, null);
|
|
36
|
+
|
|
37
|
+
var args = new object[]
|
|
38
|
+
{ 0.125f, 8, 0.15f * Preferences.VfxGraphZoomStep, 1 };
|
|
39
|
+
setupZoomMethod.Invoke(graphView, args);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
} // namespace Klak.KlutterTools
|
package/Editor.meta
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
package/LICENSE.meta
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Klutter Tools
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
**Klutter Tools** is a collection of Unity Editor extensions offering various
|
|
6
|
+
utilities to enhance the editor workflow.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
Currently, the package includes the following features:
|
|
11
|
+
|
|
12
|
+
### FPS capper
|
|
13
|
+
|
|
14
|
+
**FPS Capper** allows you to set preferences for limiting the frame rate in the
|
|
15
|
+
Unity Editor. This is particularly useful when editing VFX Graphs in Edit Mode,
|
|
16
|
+
as V-Sync settings are ignored in this mode, which can lead to unnecessary
|
|
17
|
+
energy consumption, heat and fan noise.
|
|
18
|
+
|
|
19
|
+
### Zoom step scaling in VFX Graph Editor
|
|
20
|
+
|
|
21
|
+
This feature provides a preference setting to customize the zoom step scaling
|
|
22
|
+
in the VFX Graph Editor. It's especially helpful for Mac users with a trackpad,
|
|
23
|
+
where scroll gestures can feel overly sensitive and make precise editing
|
|
24
|
+
difficult.
|
|
25
|
+
|
|
26
|
+
### .cube LUT file import
|
|
27
|
+
|
|
28
|
+
Adds support for importing `.cube` LUT (Look-Up Table) files, commonly used in
|
|
29
|
+
video editing software. While this feature is natively available in HDRP, it’s
|
|
30
|
+
beneficial for users who want to use it in URP.
|
|
31
|
+
|
|
32
|
+
## System Requirements
|
|
33
|
+
|
|
34
|
+
- Unity 6 or later
|
|
35
|
+
|
|
36
|
+
## How to Install
|
|
37
|
+
|
|
38
|
+
The Klutter Tools package (`jp.keijiro.klutter-tools`) can be installed via the
|
|
39
|
+
"Keijiro" scoped registry using Package Manager. To add the registry to your
|
|
40
|
+
project, please follow [these instructions].
|
|
41
|
+
|
|
42
|
+
[these instructions]:
|
|
43
|
+
https://gist.github.com/keijiro/f8c7e8ff29bfe63d86b888901b82644c
|
package/README.md.meta
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jp.keijiro.klutter-tools",
|
|
3
|
+
"displayName": "Klutter Tools",
|
|
4
|
+
"description": "Miscellaneous editor tools.",
|
|
5
|
+
"author": "Keijiro Takahashi",
|
|
6
|
+
"license": "Unlicense",
|
|
7
|
+
"dependencies": { },
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"unity": "6000.0",
|
|
10
|
+
"keywords": [ "unity" ]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|