新增动态水物理插件
This commit is contained in:
8
Packages/com.nwh.common/Runtime/NUI/Editor.meta
Normal file
8
Packages/com.nwh.common/Runtime/NUI/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 553b71a9f03c40a4d8551653823451e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a804ce60c07e08648b7961d49d7c2999
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57bf16eb97e2c164f997df4cf6c27e38
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 146 B |
@@ -0,0 +1,103 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fec6694e308c524bb292f84e8eafdc2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 126 B |
@@ -0,0 +1,103 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87a3220b3c062c0449c545ddc8473dc8
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1,103 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38e8124ac66cf414bbe9ba84c4628ae3
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
301
Packages/com.nwh.common/Runtime/NUI/EditorCache.cs
Normal file
301
Packages/com.nwh.common/Runtime/NUI/EditorCache.cs
Normal file
@@ -0,0 +1,301 @@
|
||||
// ╔════════════════════════════════════════════════════════════════╗
|
||||
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
|
||||
// ║ Licensed under Unity Asset Store Terms of Service: ║
|
||||
// ║ https://unity.com/legal/as-terms ║
|
||||
// ║ Use permitted only in compliance with the License. ║
|
||||
// ║ Distributed "AS IS", without warranty of any kind. ║
|
||||
// ╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#region
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace NWH.NUI
|
||||
{
|
||||
public static class EditorCache
|
||||
{
|
||||
// Workaround to get around the issue of .NET 2.0, asmdef and dynamic.
|
||||
private static readonly Dictionary<string, float> heightCache = new();
|
||||
|
||||
private static readonly Dictionary<string, ReorderableList> reorderableListCache = new();
|
||||
|
||||
private static readonly Dictionary<string, bool> guiWasEnabledCache = new();
|
||||
private static readonly Dictionary<string, NUIEditor> nuiEditorCache = new();
|
||||
private static readonly Dictionary<string, bool> isExpandedCache = new();
|
||||
private static readonly Dictionary<string, int> tabIndexCache = new();
|
||||
private static readonly Dictionary<string, Texture2D> texture2DCache = new();
|
||||
|
||||
private static readonly Dictionary<string, SerializedProperty> serializedPropertyCache = new();
|
||||
|
||||
// Auto-clear cache on assembly reload to prevent unbounded growth
|
||||
[UnityEditor.Callbacks.DidReloadScripts]
|
||||
private static void OnScriptsReloaded()
|
||||
{
|
||||
ClearAll();
|
||||
}
|
||||
|
||||
|
||||
public static bool GetHeightCacheValue(string key, ref float value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return heightCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetReorderableListCacheValue(string key, ref ReorderableList value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return reorderableListCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetGuiWasEnabledCValue(string key, ref bool value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return guiWasEnabledCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetNUIEditorCacheValue(string key, ref NUIEditor value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return nuiEditorCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetIsExpandedCacheValue(string key, ref bool value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isExpandedCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetTabIndexCacheValue(string key, ref int value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return tabIndexCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetTexture2DCacheValue(string key, ref Texture2D value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return texture2DCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool GetSerializedPropertyCacheValue(string key, ref SerializedProperty value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return serializedPropertyCache.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
|
||||
public static bool SetHeightCacheValue(string key, float value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
heightCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetReorderableListCacheValue(string key, ReorderableList value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
reorderableListCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetGuiWasEnabledCacheValue(string key, bool value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
guiWasEnabledCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetNUIEditorCacheValue(string key, NUIEditor value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
nuiEditorCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetIsExpandedCacheValue(string key, bool value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
isExpandedCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetTabIndexCacheValue(string key, int value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tabIndexCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetTexture2DCacheValue(string key, Texture2D value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
texture2DCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool SetSerializedPropertyCacheValue(string key, SerializedProperty value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
serializedPropertyCache[key] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clears all cached data. Useful to prevent unbounded memory growth during long editor sessions.
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
heightCache.Clear();
|
||||
reorderableListCache.Clear();
|
||||
guiWasEnabledCache.Clear();
|
||||
nuiEditorCache.Clear();
|
||||
isExpandedCache.Clear();
|
||||
tabIndexCache.Clear();
|
||||
texture2DCache.Clear();
|
||||
serializedPropertyCache.Clear();
|
||||
}
|
||||
|
||||
|
||||
// // Store data for each property as property drawer gets reused multiple times and local values overwritten
|
||||
// private static readonly Dictionary<string, dynamic> Cache = new Dictionary<string, dynamic>
|
||||
// {
|
||||
// {"height", new Dictionary<string, float>()},
|
||||
// {"ReorderableList", new Dictionary<string, ReorderableList>()},
|
||||
// {"guiWasEnabled", new Dictionary<string, bool>()},
|
||||
// {"NUIEditor", new Dictionary<string, NUIEditor>()},
|
||||
// {"isExpanded", new Dictionary<string, bool>()},
|
||||
// {"tabIndex", new Dictionary<string, int>()},
|
||||
// {"Texture2D", new Dictionary<string, Texture2D>()},
|
||||
// {"SerializedProperty", new Dictionary<string, SerializedProperty>()},
|
||||
// };
|
||||
|
||||
// public static bool GetCachedValue<T>(string variableName, ref T value, string key)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(key))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (!Cache.ContainsKey(variableName) || !Cache[variableName].ContainsKey(key))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// value = Cache[variableName][key];
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static bool SetCachedValue<T>(string variableName, T value, string key)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(key))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (Cache.ContainsKey(variableName))
|
||||
// {
|
||||
// if (!Cache[variableName].ContainsKey(key))
|
||||
// {
|
||||
// Cache[variableName].Add(key, value);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Cache[variableName][key] = value;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Packages/com.nwh.common/Runtime/NUI/EditorCache.cs.meta
Normal file
11
Packages/com.nwh.common/Runtime/NUI/EditorCache.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cf6a4455b5e57544b00112d46ccf043
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1014
Packages/com.nwh.common/Runtime/NUI/NUIDrawer.cs
Normal file
1014
Packages/com.nwh.common/Runtime/NUI/NUIDrawer.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Packages/com.nwh.common/Runtime/NUI/NUIDrawer.cs.meta
Normal file
11
Packages/com.nwh.common/Runtime/NUI/NUIDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f9ca09d742ea9d469503cf7022161fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Packages/com.nwh.common/Runtime/NUI/NUIEditor.cs
Normal file
87
Packages/com.nwh.common/Runtime/NUI/NUIEditor.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
// ╔════════════════════════════════════════════════════════════════╗
|
||||
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
|
||||
// ║ Licensed under Unity Asset Store Terms of Service: ║
|
||||
// ║ https://unity.com/legal/as-terms ║
|
||||
// ║ Use permitted only in compliance with the License. ║
|
||||
// ║ Distributed "AS IS", without warranty of any kind. ║
|
||||
// ╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#region
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace NWH.NUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Base custom editor class for NWH NUI (NWH User Interface) system.
|
||||
/// Provides common infrastructure for drawing foldable inspector sections with documentation links.
|
||||
/// </summary>
|
||||
[CanEditMultipleObjects]
|
||||
public class NUIEditor : Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// NUIDrawer instance used to render inspector GUI.
|
||||
/// </summary>
|
||||
public NUIDrawer drawer = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unity callback to draw inspector GUI. Delegates to OnInspectorNUI.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
OnInspectorNUI();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draws custom NUI inspector. Override this method in derived classes to add custom GUI.
|
||||
/// Initializes drawer and renders collapsible header.
|
||||
/// </summary>
|
||||
/// <returns>True if header is expanded and GUI should continue, false if collapsed</returns>
|
||||
public virtual bool OnInspectorNUI()
|
||||
{
|
||||
if (drawer == null)
|
||||
{
|
||||
drawer = new NUIDrawer();
|
||||
}
|
||||
|
||||
drawer.documentationBaseURL = GetDocumentationBaseURL();
|
||||
|
||||
drawer.BeginEditor(serializedObject);
|
||||
if (!drawer.Header(serializedObject.targetObject.GetType().Name))
|
||||
{
|
||||
drawer.EndEditor();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets base URL for documentation links. Override in derived classes to specify package-specific docs.
|
||||
/// </summary>
|
||||
/// <returns>Base documentation URL</returns>
|
||||
public virtual string GetDocumentationBaseURL()
|
||||
{
|
||||
return "http://nwhvehiclephysics.com";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Disables default Unity inspector margins for custom NUI layout control.
|
||||
/// </summary>
|
||||
/// <returns>Always false to disable default margins</returns>
|
||||
public override bool UseDefaultMargins()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Packages/com.nwh.common/Runtime/NUI/NUIEditor.cs.meta
Normal file
11
Packages/com.nwh.common/Runtime/NUI/NUIEditor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 265c8a5e778724d40bdd0fa7f07534e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Packages/com.nwh.common/Runtime/NUI/NUIPropertyDrawer.cs
Normal file
73
Packages/com.nwh.common/Runtime/NUI/NUIPropertyDrawer.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
// ╔════════════════════════════════════════════════════════════════╗
|
||||
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
|
||||
// ║ Licensed under Unity Asset Store Terms of Service: ║
|
||||
// ║ https://unity.com/legal/as-terms ║
|
||||
// ║ Use permitted only in compliance with the License. ║
|
||||
// ║ Distributed "AS IS", without warranty of any kind. ║
|
||||
// ╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#region
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace NWH.NUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom NWH.NUI property drawer with links to documentation.
|
||||
/// </summary>
|
||||
public class NUIPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
protected NUIDrawer drawer = new();
|
||||
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
return drawer.GetHeight(NUIDrawer.GenerateKey(property));
|
||||
}
|
||||
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
OnNUI(position, property, label);
|
||||
}
|
||||
|
||||
|
||||
public virtual string GetDocumentationBaseURL()
|
||||
{
|
||||
return "http://nwhvehiclephysics.com";
|
||||
}
|
||||
|
||||
|
||||
public virtual bool OnNUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (drawer == null)
|
||||
{
|
||||
drawer = new NUIDrawer();
|
||||
}
|
||||
|
||||
drawer.documentationBaseURL = GetDocumentationBaseURL();
|
||||
drawer.BeginProperty(position, property, label);
|
||||
|
||||
string name = property.FindPropertyRelative("name")?.stringValue;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
name = property.displayName;
|
||||
}
|
||||
|
||||
if (!drawer.Header(name))
|
||||
{
|
||||
drawer.EndProperty();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d441a0a5e57f9444d89059c8b692ec7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Packages/com.nwh.common/Runtime/NUI/NUISettings.cs
Normal file
78
Packages/com.nwh.common/Runtime/NUI/NUISettings.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
// ╔════════════════════════════════════════════════════════════════╗
|
||||
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
|
||||
// ║ Licensed under Unity Asset Store Terms of Service: ║
|
||||
// ║ https://unity.com/legal/as-terms ║
|
||||
// ║ Use permitted only in compliance with the License. ║
|
||||
// ║ Distributed "AS IS", without warranty of any kind. ║
|
||||
// ╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
#region
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace NWH.NUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Global configuration settings for NWH NUI (NWH User Interface) editor system.
|
||||
/// Defines layout constants and color scheme used across all NWH custom editors.
|
||||
/// </summary>
|
||||
public static class NUISettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Standard height for inspector fields in pixels.
|
||||
/// </summary>
|
||||
public const float fieldHeight = 23f;
|
||||
|
||||
/// <summary>
|
||||
/// Vertical spacing between inspector fields in pixels.
|
||||
/// </summary>
|
||||
public const float fieldSpacing = 3f;
|
||||
|
||||
/// <summary>
|
||||
/// Resources folder path for NUI assets.
|
||||
/// </summary>
|
||||
public const string resourcesPath = "NUI/";
|
||||
|
||||
/// <summary>
|
||||
/// Margin around text elements in pixels.
|
||||
/// </summary>
|
||||
public const float textMargin = 2f;
|
||||
|
||||
/// <summary>
|
||||
/// Header background color for ScriptableObject editors.
|
||||
/// </summary>
|
||||
public static Color scriptableObjectHeaderColor = new Color32(220, 122, 32, 255);
|
||||
|
||||
/// <summary>
|
||||
/// Header background color for MonoBehaviour editors.
|
||||
/// </summary>
|
||||
public static Color editorHeaderColor = new Color32(20, 125, 211, 255);
|
||||
|
||||
/// <summary>
|
||||
/// Header background color for property drawers.
|
||||
/// </summary>
|
||||
public static Color propertyHeaderColor = new Color32(78, 152, 213, 255);
|
||||
|
||||
/// <summary>
|
||||
/// UI tint color indicating disabled state.
|
||||
/// </summary>
|
||||
public static Color disabledColor = new(1f, 0.5f, 0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// UI tint color indicating enabled state.
|
||||
/// </summary>
|
||||
public static Color enabledColor = new(0.5f, 1f, 0.5f);
|
||||
|
||||
/// <summary>
|
||||
/// Light blue accent color for UI elements.
|
||||
/// </summary>
|
||||
public static Color lightBlueColor = new Color32(70, 170, 220, 255);
|
||||
|
||||
/// <summary>
|
||||
/// Light grey color for secondary UI elements.
|
||||
/// </summary>
|
||||
public static Color lightGreyColor = new Color32(192, 192, 192, 255);
|
||||
}
|
||||
}
|
||||
3
Packages/com.nwh.common/Runtime/NUI/NUISettings.cs.meta
Normal file
3
Packages/com.nwh.common/Runtime/NUI/NUISettings.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4569c8453c17406d83a470d6e849d57f
|
||||
timeCreated: 1581892208
|
||||
145
Packages/com.nwh.common/Runtime/NUI/SerializedPropertyHelper.cs
Normal file
145
Packages/com.nwh.common/Runtime/NUI/SerializedPropertyHelper.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
// ╔════════════════════════════════════════════════════════════════╗
|
||||
// ║ Copyright © 2025 NWH Coding d.o.o. All rights reserved. ║
|
||||
// ║ Licensed under Unity Asset Store Terms of Service: ║
|
||||
// ║ https://unity.com/legal/as-terms ║
|
||||
// ║ Use permitted only in compliance with the License. ║
|
||||
// ║ Distributed "AS IS", without warranty of any kind. ║
|
||||
// ╚════════════════════════════════════════════════════════════════╝
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
#region
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace NWH.NUI
|
||||
{
|
||||
public static class SerializedPropertyHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the object the property represents.
|
||||
/// </summary>
|
||||
/// <param name="prop"> </param>
|
||||
/// <returns> </returns>
|
||||
public static object GetTargetObjectOfProperty(SerializedProperty prop)
|
||||
{
|
||||
if (prop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string path = prop.propertyPath.Replace(".Array.data[", "[");
|
||||
object obj = prop.serializedObject.targetObject;
|
||||
string[] elements = path.Split('.');
|
||||
foreach (string element in elements)
|
||||
{
|
||||
if (element.Contains("["))
|
||||
{
|
||||
string elementName = element.Substring(0, element.IndexOf("["));
|
||||
int index = Convert.ToInt32(element.Substring(element.IndexOf("[")).Replace("[", "")
|
||||
.Replace("]", ""));
|
||||
obj = GetValue_Imp(obj, elementName, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = GetValue_Imp(obj, element);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object that the property is a member of
|
||||
/// </summary>
|
||||
/// <param name="prop"> </param>
|
||||
/// <returns> </returns>
|
||||
public static object GetTargetObjectWithProperty(SerializedProperty prop)
|
||||
{
|
||||
string path = prop.propertyPath.Replace(".Array.data[", "[");
|
||||
object obj = prop.serializedObject.targetObject;
|
||||
string[] elements = path.Split('.');
|
||||
foreach (string element in elements.Take(elements.Length - 1))
|
||||
{
|
||||
if (element.Contains("["))
|
||||
{
|
||||
string elementName = element.Substring(0, element.IndexOf("["));
|
||||
int index = Convert.ToInt32(element.Substring(element.IndexOf("[")).Replace("[", "")
|
||||
.Replace("]", ""));
|
||||
obj = GetValue_Imp(obj, elementName, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = GetValue_Imp(obj, element);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
private static object GetValue_Imp(object source, string name)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Type type = source.GetType();
|
||||
|
||||
while (type != null)
|
||||
{
|
||||
FieldInfo f = type.GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||
if (f != null)
|
||||
{
|
||||
return f.GetValue(source);
|
||||
}
|
||||
|
||||
PropertyInfo p = type.GetProperty(name,
|
||||
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |
|
||||
BindingFlags.IgnoreCase);
|
||||
if (p != null)
|
||||
{
|
||||
return p.GetValue(source, null);
|
||||
}
|
||||
|
||||
type = type.BaseType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static object GetValue_Imp(object source, string name, int index)
|
||||
{
|
||||
IEnumerable enumerable = GetValue_Imp(source, name) as IEnumerable;
|
||||
if (enumerable == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IEnumerator enm = enumerable.GetEnumerator();
|
||||
//while (index-- >= 0)
|
||||
// enm.MoveNext();
|
||||
//return enm.Current;
|
||||
|
||||
for (int i = 0; i <= index; i++)
|
||||
{
|
||||
if (!enm.MoveNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return enm.Current;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76156108e69e9ba4897a469d702f4d40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user