完成编队 增加多个细节和小功能

This commit is contained in:
2025-12-10 19:12:27 +08:00
parent c0a822b958
commit edc2608f47
131 changed files with 11889 additions and 127 deletions
@@ -0,0 +1,157 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
namespace SmoothShakeFree
{
public static class EditorUtility
{
#if UNITY_2020
public static Color SmoothShakeFreeColor = new Color(0.78f, 0.78f, 0.78f);
#else
public static Color SmoothShakeFreeColor = new(0.78f, 0.78f, 0.78f);
#endif
public static void DrawTitle(string title)
{
//-------------------------------------------
// Create a custom GUIStyle
GUIStyle titleStyle = new GUIStyle(EditorStyles.boldLabel);
titleStyle.fontSize = 18; // Adjust the font size as needed
titleStyle.fontStyle = FontStyle.Bold;
titleStyle.alignment = TextAnchor.MiddleCenter;
//-------------------------------------------
EditorGUILayout.LabelField(title, titleStyle);
EditorGUILayout.GetControlRect(false, 10);
}
public static void DrawUILine(Color color, int thickness = 2, int padding = 10)
{
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
r.height = thickness;
r.y += padding / 2;
r.x -= 2;
r.width += 6;
EditorGUI.DrawRect(r, color);
}
public static void DisplaySerializedProperties(SerializedObject obj, params string[] properties)
{
foreach (string property in properties)
{
SerializedProperty myDataProperty = obj.FindProperty(property);
if (myDataProperty == null)
{
Debug.LogError("Property '" + property + "' not found!");
continue;
}
EditorGUILayout.PropertyField(myDataProperty, true);
obj.ApplyModifiedProperties();
}
}
public static void DrawSerializedProperties(SerializedProperty property, ref Rect position, float padding, params string[] properties)
{
for (int i = 0; i < properties.Length; i++)
{
SerializedProperty newProperty = property.FindPropertyRelative(properties[i]);
if (newProperty == null)
Debug.LogError("Property '" + properties[i] + "' not found!");
float propertyHeight = EditorGUI.GetPropertyHeight(newProperty);
Rect fieldRect = new Rect(position.x, position.y, position.width, propertyHeight);
EditorGUI.PropertyField(fieldRect, newProperty);
position.y += propertyHeight + padding;
}
}
public static string AddSpacesToSentence(string text, bool preserveAcronyms = true)
{
if (string.IsNullOrWhiteSpace(text))
return string.Empty;
string newText = Regex.Replace(text, "([a-z])([A-Z])", "$1 $2");
if (preserveAcronyms)
{
newText = Regex.Replace(newText, "([A-Z])([A-Z][a-z])", "$1 $2");
}
return newText;
}
public static void DrawPropertiesHorizontally(SerializedProperty property, ref Rect position, string label, float padding, float minWidth, float[] weight, params string[] properties)
{
if (position.width < 5) return;
Rect[] rects = new Rect[properties.Length];
float[] minWidths = new float[properties.Length];
for (int i = 0; i < minWidths.Length; i++) minWidths[i] = minWidth;
Rect rect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
SplitRectsHorizontally(rect, padding, minWidths, weight, ref rects);
for (int i = 0; i < properties.Length; i++)
{
if (i == 0) EditorGUI.PropertyField(rects[0], property.FindPropertyRelative(properties[0]), new GUIContent(label));
else EditorGUI.PropertyField(rects[i], property.FindPropertyRelative(properties[i]), GUIContent.none);
}
position.y += EditorGUIUtility.singleLineHeight + padding;
}
public static void DrawDropdown(SerializedProperty property, ref Rect position, float padding, string label, string propertypath)
{
float dropdownHeight = EditorGUI.GetPropertyHeight(property.FindPropertyRelative(propertypath));
Rect dropdownRect = new Rect(position.x, position.y, position.width, dropdownHeight);
EditorGUI.PropertyField(dropdownRect, property.FindPropertyRelative(propertypath), new GUIContent(label));
position.y += dropdownHeight + padding;
}
public static bool ThinView(float viewWidth = 330f)
{
if (EditorGUIUtility.currentViewWidth > viewWidth)
return false;
else
return true;
}
//------------------
//Credit for this section goes to Wessel van der Es
public static void SplitRectsHorizontally(this Rect rect, float space, float[] minWidths, float[] weights, ref Rect[] rects)
{
int count = weights.Length;
float budget = rect.width - (count - 1) * space - minWidths.Sum();
float totalWeight = weights.Sum();
float offset = 0.0f;
float error = 0.0f;
for (int i = 0; i < count; i++)
{
rects[i] = rect;
rects[i].x += offset;
rects[i].width = minWidths[i] + weights[i] / totalWeight * budget + error;
float rounded = Mathf.Round(rects[i].width);
error = rects[i].width - rounded;
rects[i].width = rounded;
offset += rects[i].width + space;
}
}
public static float Sum(this IEnumerable<float> numbers)
{
float sum = 0.0f;
foreach (float number in numbers)
sum += number;
return sum;
}
//------------------
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0cd3d6475f5fc654b8f15e75e854c3e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/EditorUtility.cs
uploadId: 656168
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f7466c00f029c2e46aa5ba478ff9ae38
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: ce2446e8e0ad47b4c8554496daa9625e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
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
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
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
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/Icons/Icon_Default.png
uploadId: 656168
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: 78fc80bb49a6807458a322585a480e98
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
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
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
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
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/Icons/Icon_Default_base.png
uploadId: 656168
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: cda6f08464b9f844c82e8ff0b03d06be
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
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
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
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
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/Icons/Icon_SmoothShake_Base.png
uploadId: 656168
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

@@ -0,0 +1,134 @@
fileFormatVersion: 2
guid: c0e8b27d7173b314fa78f14aa3686f8e
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
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
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
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
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 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
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/Icons/Icon_SmoothShake_Preset.png
uploadId: 656168
@@ -0,0 +1,82 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace SmoothShakeFree
{
[CustomEditor(typeof(ShakeBase), true)]
internal class ShakeBaseEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.Update();
ShakeBase shakeBase = (ShakeBase)target;
EditorUtility.DrawTitle("Smooth Shake Free");
EditorUtility.DrawUILine(EditorUtility.SmoothShakeFreeColor, 1, 10);
if(shakeBase is SmoothShake ssf)
{
DrawPresetInspector(ssf.preset, ssf);
}
EditorUtility.DrawUILine(Color.gray, 1, 10);
//Draw test buttons
DrawTestButtons(shakeBase);
serializedObject.ApplyModifiedProperties();
}
private void DrawPresetInspector(SmoothShakeFreePreset preset, ShakeBase shakeBase)
{
//Draw preset property
EditorGUILayout.PropertyField(serializedObject.FindProperty("preset"), true);
if (preset)
{
if (!Application.isPlaying) shakeBase.ApplyPresetSettings(preset);
//Helpbox
EditorGUILayout.HelpBox("This shake being overriden by " + preset.name, MessageType.Info);
EditorGUILayout.BeginHorizontal();
{
if (GUILayout.Button("Go To Preset"))
{
Selection.activeObject = preset;
}
}
EditorGUILayout.EndHorizontal();
}
else
{
DrawPropertiesExcluding(serializedObject, "m_Script", "preset");
}
}
void DrawTestButtons(ShakeBase shakeBase)
{
//Test start and stop buttons in horizontal
EditorGUILayout.BeginHorizontal();
{
//Disable buttons in edit mode
GUI.enabled = Application.isPlaying;
if (GUILayout.Button("Test Shake"))
shakeBase.StartShake();
if (GUILayout.Button("Stop Test Shake"))
shakeBase.StopShake();
if (GUILayout.Button("Force Stop Test Shake"))
shakeBase.ForceStop();
}
EditorGUILayout.EndHorizontal();
if (!GUI.enabled)
EditorGUILayout.HelpBox("You can only test shakes play mode", MessageType.Info);
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e6b6befad0fd07b4c9c0f9c06aa9dc23
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/ShakeBaseEditor.cs
uploadId: 656168
@@ -0,0 +1,21 @@
#if UNITY_EDITOR
using UnityEditor;
namespace SmoothShakeFree
{
[CustomEditor(typeof(SmoothShakeFreePreset), true)]
internal class ShakeBasePresetEditor : Editor
{
public override void OnInspectorGUI()
{
EditorUtility.DrawTitle("Smooth Shake Free");
EditorUtility.DrawUILine(EditorUtility.SmoothShakeFreeColor, 1, 10);
serializedObject.Update();
DrawPropertiesExcluding(serializedObject, "m_Script");
serializedObject.ApplyModifiedProperties();
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: edf83b5628d981b41a75cf5009f1e4e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/ShakeBasePresetEditor.cs
uploadId: 656168
@@ -0,0 +1,107 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using static SmoothShakeFree.Shaker;
namespace SmoothShakeFree
{
[CustomPropertyDrawer(typeof(Shaker))]
internal class ShakerDrawer : PropertyDrawer
{
private readonly float padding = 2f;
//Init foldoutStates
#if UNITY_2020
private static Dictionary<string, bool> foldoutStates = new Dictionary<string, bool>();
#else
private static Dictionary<string, bool> foldoutStates = new();
#endif
//-----------------------------------------------------------------------------------------
//Noise type implementation
//Noise type variable setup
private readonly string[] waveVariables = new string[] { "amplitude", "frequency" };
private readonly string[] baseVariables = new string[] { "amplitude" };
public void DrawNoiseTypeSettings(Rect position, SerializedProperty property, NoiseType noiseType)
{
switch (noiseType)
{
case NoiseType.SineWave:
EditorUtility.DrawSerializedProperties(property, ref position, padding, waveVariables);
break;
case NoiseType.WhiteNoise:
EditorUtility.DrawSerializedProperties(property, ref position, padding, baseVariables);
break;
}
}
public float GetPropertyAmount(NoiseType noiseType) => noiseType switch
{
NoiseType.SineWave => waveVariables.Length,
NoiseType.WhiteNoise => baseVariables.Length,
_ => throw new System.Exception("Unknown noise type")
};
//-----------------------------------------------------------------------------------------
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
//Get noise type info
SerializedProperty noiseTypeProperty = property.FindPropertyRelative("noiseType");
NoiseType noiseType = (NoiseType)noiseTypeProperty.enumValueIndex;
// Draw foldout
InitFoldout(property, out string key);
DrawFoldout(ref position, noiseType, key);
if (!foldoutStates[key]) return;
//Draw the noiseType property
EditorUtility.DrawDropdown(property, ref position, padding, "Noise Type", "noiseType");
// Draw fields based on the selected noiseType
DrawNoiseTypeSettings(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight), property, noiseType);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
InitFoldout(property, out string key);
if (!foldoutStates[key]) return EditorGUIUtility.singleLineHeight + padding;
//Add height for foldout
float foldoutHeight = EditorGUIUtility.singleLineHeight + padding;
//Add height for noiseType property
NoiseType noiseType = (NoiseType)property.FindPropertyRelative("noiseType").enumValueIndex;
float propertiesHeight = GetPropertyAmount(noiseType) * (EditorGUIUtility.singleLineHeight + padding) + padding;
if (EditorUtility.ThinView()) propertiesHeight += GetPropertyAmount(noiseType) * (EditorGUIUtility.singleLineHeight + padding);
return foldoutHeight + propertiesHeight + (EditorGUIUtility.singleLineHeight + padding) + padding;
}
private void InitFoldout(SerializedProperty property, out string key)
{
key = GetFoldoutKey(property);
// Initialize foldout state if not present
if (!foldoutStates.ContainsKey(key))
{
foldoutStates[key] = false;
}
}
private void DrawFoldout(ref Rect position, NoiseType noiseType, string key)
{
foldoutStates[key] = EditorGUI.Foldout(new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight + padding), foldoutStates[key], "Shake Settings", true);
position.y += EditorGUIUtility.singleLineHeight + padding;
}
private string GetFoldoutKey(SerializedProperty property)
{
return property.serializedObject.targetObject.GetInstanceID() + "-" + property.propertyPath;
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 1ca3e0c191d9ee347989dc612e7472c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/ShakerDrawer.cs
uploadId: 656168
@@ -0,0 +1,32 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace SmoothShakeFree
{
[CustomPropertyDrawer(typeof(TimeSettings))]
internal class TimeSettingsDrawer : PropertyDrawer
{
public float padding = 2f;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
//Draw enableOnStart and constantShake
EditorUtility.DrawSerializedProperties(property, ref position, padding, "enableOnStart", "constantShake");
// Draw fadeInDuration and fadeInCurve
EditorUtility.DrawPropertiesHorizontally(property, ref position, "Fade In", padding, 25f, new float[] { 1.5f, 1 }, "fadeInDuration", "fadeInCurve");
// Draw holdDuration
EditorUtility.DrawSerializedProperties(property, ref position, padding, "holdDuration");
// Draw fadeOutDuration and fadeOutCurve
EditorUtility.DrawPropertiesHorizontally(property, ref position, "Fade Out", padding, 25f, new float[] { 1.5f, 1 }, "fadeOutDuration", "fadeOutCurve");
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return (EditorGUIUtility.singleLineHeight + padding) * 5;
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 53770111b3244694ba8d48649c29f0b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/TimeSettingsDrawer.cs
uploadId: 656168
@@ -0,0 +1,31 @@
#if UNITY_EDITOR
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace SmoothShakeFree
{
internal class WindowLinks : Editor
{
[MenuItem("Window/SmoothShakeFree/Upgrade to Pro version")]
public static void ProLink()
{
Application.OpenURL("https://assetstore.unity.com/packages/tools/animation/smooth-shake-pro-271080");
}
[MenuItem("Window/SmoothShakeFree/Showcase and Tutorial")]
public static void TutorialLink()
{
Application.OpenURL("https://youtu.be/SFpfRgB9yh0?si=8H1EVeIFZ1tNjTdt");
}
//Leave a review
[MenuItem("Window/SmoothShakeFree/Leave a review")]
public static void ReviewLink()
{
Application.OpenURL("https://assetstore.unity.com/packages/tools/animation/smooth-shake-free-271263#reviews");
}
}
}
#endif
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6be097daa292f614ca08ebeb7e893fea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: ce2446e8e0ad47b4c8554496daa9625e, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 271263
packageName: Smooth Shake Free
packageVersion: 1.0.2
assetPath: Assets/SmoothShakeFree/Data/Editor/WindowLinks.cs
uploadId: 656168