This commit is contained in:
2025-08-18 09:22:24 +08:00
commit cef5623ab0
1333 changed files with 305844 additions and 0 deletions
@@ -0,0 +1,60 @@
// Pre-2019.1 Unity versions have performance problems with the Shadow script,
// while 2019.{1,2,3,4} sometimes have problems with displaying an Image+Shadow
#if UNITY_2019_1_OR_NEWER && !(UNITY_2019_1_0 || UNITY_2019_1_1 || UNITY_2019_1_2 || UNITY_2019_1_3 || UNITY_2019_1_4)
#define ALLOW_SHADOWS
#endif
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace Com.ForbiddenByte.OSA.Util.Optimization
{
/// <summary>
/// Simple: If no Unity 2019, no shadow (the shadow will be destroyed).
/// Seems like a lot of Shadow components used cause significant FPS drops
/// </summary>
[ExecuteInEditMode]
public class ShadowRemover : MonoBehaviour
{
// If not on a compatible unity version, destroy the Shadow script and this script
#if ALLOW_SHADOWS
#else
[SerializeField]
[HideInInspector]
Shadow _Shadow;
void Awake()
{
if (!_Shadow)
_Shadow = GetComponent<Shadow>();
if (!Application.isPlaying)
return;
// In play mode, destroy it
if (_Shadow)
{
Destroy(_Shadow);
_Shadow = null;
}
Destroy(this);
}
#if UNITY_EDITOR
void Update()
{
// No checks during play mode
if (Application.isPlaying)
return;
if (!_Shadow)
_Shadow = GetComponent<Shadow>();
}
#endif
#endif
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1a97ab825bf3ba44d81da6a6ce5c66fa
timeCreated: 1563293088
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: