jp.keijiro.klutter-tools 1.0.0 → 2.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.
@@ -4,7 +4,7 @@ using System.IO;
4
4
  using UnityEditor.AssetImporters;
5
5
  using UnityEngine;
6
6
 
7
- namespace Klak.KlutterTools {
7
+ namespace KlutterTools {
8
8
 
9
9
  #if !KLUTTER_TOOLS_HAS_HDRP
10
10
 
@@ -60,4 +60,4 @@ class CubeLutImporter : ScriptedImporter
60
60
 
61
61
  #endif
62
62
 
63
- } // namespace Klak.KlutterTools
63
+ } // namespace KlutterTools
@@ -2,7 +2,7 @@ using UnityEditor;
2
2
  using UnityEngine;
3
3
  using System.Threading;
4
4
 
5
- namespace Klak.KlutterTools {
5
+ namespace KlutterTools {
6
6
 
7
7
  // FPS Capper player loop sub system
8
8
  [InitializeOnLoad]
@@ -53,4 +53,4 @@ sealed class FpsCapperSystem
53
53
  }
54
54
  }
55
55
 
56
- } // namespace Klak.KlutterTools
56
+ } // namespace KlutterTools
@@ -0,0 +1,71 @@
1
+ using UnityEngine;
2
+ using UnityEditor;
3
+ using System.Reflection;
4
+ using System.Linq;
5
+
6
+ namespace KlutterTools.InspectorUtils {
7
+
8
+ // String container providing GUIContent
9
+ public struct LabelString
10
+ {
11
+ GUIContent _guiContent;
12
+
13
+ public static implicit operator GUIContent(LabelString label)
14
+ => label._guiContent;
15
+
16
+ public static implicit operator LabelString(string text)
17
+ => new LabelString { _guiContent = new GUIContent(text) };
18
+ }
19
+
20
+ // Auto-scanning serialized property wrapper
21
+ public struct AutoProperty
22
+ {
23
+ SerializedProperty _prop;
24
+
25
+ public SerializedProperty Target
26
+ => _prop;
27
+
28
+ public AutoProperty(SerializedProperty prop)
29
+ => _prop = prop;
30
+
31
+ public static implicit operator AutoProperty(SerializedProperty prop)
32
+ => new AutoProperty(prop);
33
+
34
+ public static implicit operator SerializedProperty(AutoProperty prop)
35
+ => prop._prop;
36
+
37
+ public static void Scan<T>(T target) where T : UnityEditor.Editor
38
+ {
39
+ var so = target.serializedObject;
40
+
41
+ var allFields = typeof(T).GetFields
42
+ (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
43
+
44
+ var autoProps = allFields.Where(f => f.FieldType == typeof(AutoProperty));
45
+
46
+ foreach (var f in autoProps)
47
+ f.SetValue(target, new AutoProperty(FindProperty(so, f.Name)));
48
+ }
49
+
50
+ static string GetPropNameBacking(string name)
51
+ => $"<{name}>k__BackingField";
52
+
53
+ static string GetPropNameCamel(string name)
54
+ => name.TrimStart('_');
55
+
56
+ static string GetPropNamePascal(string name)
57
+ {
58
+ var trimmed = name.TrimStart('_');
59
+ return char.ToUpper(trimmed[0]) + trimmed.Substring(1);
60
+ }
61
+
62
+ static SerializedProperty FindProperty(SerializedObject so, string name)
63
+ => so.FindProperty(name) ??
64
+ so.FindProperty(GetPropNameCamel(name)) ??
65
+ so.FindProperty(GetPropNamePascal(name)) ??
66
+ so.FindProperty(GetPropNameBacking(name)) ??
67
+ so.FindProperty(GetPropNameBacking(GetPropNameCamel(name))) ??
68
+ so.FindProperty(GetPropNameBacking(GetPropNamePascal(name)));
69
+ }
70
+
71
+ } // namespace KlutterTools.InspectorUtils
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: a4362ea3b9f0e468d810ba355e03c682
@@ -16,6 +16,11 @@
16
16
  "name": "com.unity.render-pipelines.high-definition",
17
17
  "expression": "1.0.0",
18
18
  "define": "KLUTTER_TOOLS_HAS_HDRP"
19
+ },
20
+ {
21
+ "name": "com.unity.visualeffectgraph",
22
+ "expression": "1.0.0",
23
+ "define": "KLUTTER_TOOLS_HAS_VFXGRAPH"
19
24
  }
20
25
  ],
21
26
  "noEngineReferences": false
@@ -1,7 +1,7 @@
1
1
  using System;
2
2
  using UnityEngine.LowLevel;
3
3
 
4
- namespace Klak.KlutterTools {
4
+ namespace KlutterTools {
5
5
 
6
6
  public static class PlayerLoopHelper
7
7
  {
@@ -31,4 +31,4 @@ public static class PlayerLoopHelper
31
31
  }
32
32
  }
33
33
 
34
- } // namespace Klak.KlutterTools
34
+ } // namespace KlutterTools
@@ -1,7 +1,7 @@
1
1
  using UnityEditor;
2
2
  using UnityEngine;
3
3
 
4
- namespace Klak.KlutterTools {
4
+ namespace KlutterTools {
5
5
 
6
6
  // Preference accessor
7
7
  public static class Preferences
@@ -22,13 +22,13 @@ public static class Preferences
22
22
  static class Keys
23
23
  {
24
24
  public const string FpsCapperEnable
25
- = "Klak.KlutterTools.FpsCapper.Enable";
25
+ = "KlutterTools.FpsCapper.Enable";
26
26
 
27
27
  public const string FpsCapperFrameRate
28
- = "Klak.KlutterTools.FpsCapper.FrameRate";
28
+ = "KlutterTools.FpsCapper.FrameRate";
29
29
 
30
30
  public const string VfxGraphZoomStep
31
- = "Klak.KlutterTools.VfxGraph.ZoomStep";
31
+ = "KlutterTools.VfxGraph.ZoomStep";
32
32
  }
33
33
  }
34
34
 
@@ -80,4 +80,4 @@ public sealed class PreferencesProvider : SettingsProvider
80
80
  => new PreferencesProvider();
81
81
  }
82
82
 
83
- } // namespace Klak.KlutterTools
83
+ } // namespace KlutterTools
@@ -2,7 +2,9 @@ using System;
2
2
  using System.Reflection;
3
3
  using UnityEditor;
4
4
 
5
- namespace Klak.KlutterTools {
5
+ namespace KlutterTools {
6
+
7
+ #if KLUTTER_TOOLS_HAS_VFXGRAPH
6
8
 
7
9
  [InitializeOnLoad]
8
10
  public static class VfxGraphZoomStepModifier
@@ -40,4 +42,6 @@ public static class VfxGraphZoomStepModifier
40
42
  }
41
43
  }
42
44
 
43
- } // namespace Klak.KlutterTools
45
+ #endif
46
+
47
+ } // namespace KlutterTools
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Keijiro Takahashi",
6
6
  "license": "Unlicense",
7
7
  "dependencies": { },
8
- "version": "1.0.0",
8
+ "version": "2.0.0",
9
9
  "unity": "6000.0",
10
10
  "keywords": [ "unity" ]
11
11
  }