Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 10, 2024
1 parent 388a73f commit f94c5f2
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Coffee.UISoftMaskInternal.AssetModification;
using UnityEditor;
using UnityEngine;

#pragma warning disable CS0612, CS0618 // Type or member is obsolete

Expand Down
2 changes: 1 addition & 1 deletion Editor/AssetModification/SoftMaskableShaderModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static Modifier Create(string path)
// -> color.a *= SoftMask(input.IN.vertex, IN.worldPosition, color.a);
new TextReplaceModifier(
@"(([^. \t]+).*\*=\s*SoftMask\(.*[^.][^a])\);.*$",
$"$1, $2.a); // Add for soft mask")
"$1, $2.a); // Add for soft mask")
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/AutoGeneratedEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AutoGeneratedEditor : Editor

public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox(s_Help, true);
EditorGUILayout.HelpBox(s_Help);
}
}

Expand Down
1 change: 0 additions & 1 deletion Runtime/MaskingShape/MaskingShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using UnityEngine.EventSystems;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;

namespace Coffee.UISoftMask
Expand Down
4 changes: 2 additions & 2 deletions Runtime/ProjectSettings/UISoftMaskProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public enum TransformSensitivity

#if UNITY_MODULE_VR
public static bool stereoEnabled =>
#if UNITY_EDITOR
#if UNITY_EDITOR
Application.isPlaying &&
#endif
#endif
softMaskEnabled && instance.m_StereoEnabled && XRSettings.enabled;
#else
public static bool stereoEnabled => false;
Expand Down
1 change: 0 additions & 1 deletion Runtime/SoftMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using UnityEngine.Events;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.UI;

namespace Coffee.UISoftMask
Expand Down
17 changes: 6 additions & 11 deletions Runtime/SoftMaskable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public class SoftMaskable : MonoBehaviour, IMaterialModifier, IMaskable
private int _softMaskDepth;
private int _stencilBits;

#if UNITY_EDITOR
private Action _updateSceneViewMatrix;
private static readonly int s_GameVp = Shader.PropertyToID("_GameVP");
private static readonly int s_GameTvp = Shader.PropertyToID("_GameTVP");
private static readonly int s_GameVp2 = Shader.PropertyToID("_GameVP_2");
private static readonly int s_GameTvp2 = Shader.PropertyToID("_GameTVP_2");
#endif

private bool isTerminal => _graphic is TerminalMaskingShape;

private void OnEnable()
Expand Down Expand Up @@ -198,6 +190,11 @@ private void CheckGraphic()
}

#if UNITY_EDITOR
private Action _updateSceneViewMatrix;
private static readonly int s_GameVp = Shader.PropertyToID("_GameVP");
private static readonly int s_GameTvp = Shader.PropertyToID("_GameTVP");
private static readonly int s_GameVp2 = Shader.PropertyToID("_GameVP_2");
private static readonly int s_GameTvp2 = Shader.PropertyToID("_GameTVP_2");
private void UpdateSceneViewMatrix()
{
if (!_graphic || !_graphic.canvas || !_maskableMaterial) return;
Expand All @@ -216,9 +213,7 @@ private void UpdateSceneViewMatrix()
var cam = canvas.worldCamera;
if (canvas && canvas.renderMode != RenderMode.ScreenSpaceOverlay && cam)
{
var eye = isStereo
? Camera.MonoOrStereoscopicEye.Left
: Camera.MonoOrStereoscopicEye.Mono;
var eye = isStereo ? Camera.MonoOrStereoscopicEye.Left : Camera.MonoOrStereoscopicEye.Mono;
canvas.GetViewProjectionMatrix(eye, out var vMatrix, out var pMatrix);
gameVp = gameTvp = pMatrix * vMatrix;
}
Expand Down
3 changes: 0 additions & 3 deletions Runtime/Utilities/SoftMaskUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
#if UNITY_MODULE_VR
using UnityEngine.XR;
#endif
#if TMP_ENABLE
using TMPro;
#endif
Expand Down

0 comments on commit f94c5f2

Please sign in to comment.