mirror of
https://github.com/DCFApixels/Unity-DebugX.git
synced 2025-09-18 18:14:36 +08:00
fix settings/add GreaterPassAlpha settings
This commit is contained in:
parent
862d86733d
commit
04453e4d78
@ -55,6 +55,15 @@ namespace DCFApixels.DebugXCore.Internal
|
||||
color.a = EditorGUILayout.Slider(DebugX.GlobalColor.a, 0, 1);
|
||||
DebugX.GlobalColor = color;
|
||||
|
||||
|
||||
DebugX.GlobalGreaterPassAlpha = EditorGUILayout.FloatField("GreaterPassAlpha", DebugX.GlobalGreaterPassAlpha);
|
||||
EditorGUI.BeginChangeCheck();
|
||||
tmpValue = EditorGUILayout.Slider(DebugX.GlobalGreaterPassAlpha, 0, 2);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
DebugX.GlobalGreaterPassAlpha = tmpValue;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Reset"))
|
||||
{
|
||||
DebugX.ResetGlobals();
|
||||
|
@ -23,9 +23,11 @@ namespace DCFApixels
|
||||
private const string GLOBAL_TIME_SCALE_PREF_NAME = "DCFApixels.DebugX.TimeScale";
|
||||
private const string GLOBAL_DOT_SIZE_PREF_NAME = "DCFApixels.DebugX.DotSize";
|
||||
private const string GLOBAL_COLOR_PREF_NAME = "DCFApixels.DebugX.Color";
|
||||
private const string GLOBAL_GREATER_PASS_ALPHA_PREF_NAME = "DCFApixels.DebugX.GreaterPassAlpha";
|
||||
|
||||
private readonly static int GlobalDotSizePropertyID = Shader.PropertyToID("_DebugX_GlobalDotSize");
|
||||
private readonly static int GlobalColorPropertyID = Shader.PropertyToID("_DebugX_GlobalColor");
|
||||
private readonly static int GlobalGreaterPassAlphaPropertyID = Shader.PropertyToID("_DebugX_GlobalGreaterPassAlpha");
|
||||
internal readonly static int ColorPropertyID = Shader.PropertyToID("_Color");
|
||||
|
||||
|
||||
|
@ -49,6 +49,21 @@ namespace DCFApixels
|
||||
var record = *(int*)&c32;
|
||||
#if UNITY_EDITOR
|
||||
EditorPrefs.SetInt(GLOBAL_COLOR_PREF_NAME, record);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
private static float _globalGreaterPassAlphaCache;
|
||||
public static float GlobalGreaterPassAlpha
|
||||
{
|
||||
get { return _globalGreaterPassAlphaCache; }
|
||||
set
|
||||
{
|
||||
if (_globalGreaterPassAlphaCache == value) { return; }
|
||||
_globalGreaterPassAlphaCache = value;
|
||||
Shader.SetGlobalFloat(nameID: GlobalGreaterPassAlphaPropertyID, _globalGreaterPassAlphaCache);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
EditorPrefs.SetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, _globalGreaterPassAlphaCache);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -58,22 +73,27 @@ namespace DCFApixels
|
||||
EditorPrefs.DeleteKey(GLOBAL_TIME_SCALE_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_DOT_SIZE_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_COLOR_PREF_NAME);
|
||||
EditorPrefs.DeleteKey(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME);
|
||||
#endif
|
||||
_dotSizeCache = default;
|
||||
_timeScaleCache = default;
|
||||
_dotSizeCache = default;
|
||||
_globalColorCache = default;
|
||||
_globalGreaterPassAlphaCache = default;
|
||||
InitGlobals();
|
||||
}
|
||||
private static void InitGlobals()
|
||||
{
|
||||
GlobalTimeScale = 1;
|
||||
GlobalDotSize = 1;
|
||||
GlobalColor = Color.white;
|
||||
#if UNITY_EDITOR
|
||||
GlobalTimeScale = EditorPrefs.GetFloat(GLOBAL_TIME_SCALE_PREF_NAME, 1f);
|
||||
GlobalDotSize = EditorPrefs.GetFloat(GLOBAL_DOT_SIZE_PREF_NAME, 1f);
|
||||
var colorCode = EditorPrefs.GetInt(GLOBAL_COLOR_PREF_NAME, -1);
|
||||
GlobalColor = (Color)(*(Color32*)&colorCode);
|
||||
GlobalGreaterPassAlpha = EditorPrefs.GetFloat(GLOBAL_GREATER_PASS_ALPHA_PREF_NAME, 0.1f);
|
||||
#else
|
||||
GlobalTimeScale = 1;
|
||||
GlobalDotSize = 1;
|
||||
GlobalColor = Color.white;
|
||||
GlobalGreaterPassAlpha = 0.1f;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ Shader "DCFApixels/DebugX/Handles"
|
||||
};
|
||||
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
float _DebugX_GlobalGreaterPassAlpha;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
@ -123,7 +123,8 @@ Shader "DCFApixels/DebugX/Handles"
|
||||
CGPROGRAM
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return i.color * half4(1, 1, 1, 0.1);
|
||||
//return i.color * half4(1, 1, 1, 0.1);
|
||||
return i.color * half4(1, 1, 1, _DebugX_GlobalGreaterPassAlpha);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
||||
};
|
||||
|
||||
float4 _DebugX_GlobalColor;
|
||||
|
||||
float _DebugX_GlobalGreaterPassAlpha;
|
||||
|
||||
v2g vert (appdata_t v)
|
||||
{
|
||||
@ -154,7 +154,8 @@ Shader "DCFApixels/DebugX/Handles Wire"
|
||||
CGPROGRAM
|
||||
half4 frag (g2f i) : SV_Target
|
||||
{
|
||||
return i.color * half4(1, 1, 1, 0.1);
|
||||
//return i.color * half4(1, 1, 1, 0.1);
|
||||
return i.color * half4(1, 1, 1, _DebugX_GlobalGreaterPassAlpha);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user