2025-03-18 18:23:34 +08:00
|
|
|
using System.Collections.Generic;
|
2023-10-19 15:00:19 +08:00
|
|
|
using System.ComponentModel;
|
2025-03-19 17:05:30 +08:00
|
|
|
using AOT.Common;
|
2025-03-18 12:59:43 +08:00
|
|
|
using Gameplay.Common;
|
2023-10-19 15:00:19 +08:00
|
|
|
using Gameplay.Performance;
|
|
|
|
|
using MagicaCloth2;
|
|
|
|
|
using PhxhSDK;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Rendering;
|
|
|
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
|
|
|
|
|
|
public partial class SROptions
|
|
|
|
|
{
|
2025-01-20 13:43:19 +08:00
|
|
|
|
2025-03-18 14:16:14 +08:00
|
|
|
[Category("性能"), DisplayName("限制NPC数量")]
|
|
|
|
|
public int limitUnitCount
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return CodeDefine.Fight.LIMIT_NPC_COUNT;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CodeDefine.Fight.LIMIT_NPC_COUNT = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
// 布料
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("布料开关")]
|
2023-10-19 15:00:19 +08:00
|
|
|
public bool EnableCloth
|
|
|
|
|
{
|
|
|
|
|
get { return _enableCloth; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableCloth = value;
|
|
|
|
|
PerformanceManager.instance.data.enableCloth = _enableCloth;
|
|
|
|
|
// 找到场景中的所有灯光
|
|
|
|
|
var cloths = GameObject.FindObjectsOfType<MagicaCloth>();
|
|
|
|
|
foreach (var cloth in cloths)
|
|
|
|
|
{
|
|
|
|
|
cloth.enabled = _enableCloth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableCloth = true;
|
|
|
|
|
|
2025-03-18 12:59:43 +08:00
|
|
|
[Category("性能"), DisplayName("启用战斗UI更新")]
|
|
|
|
|
public bool EnableFightSceneUI
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return !CodeDefine.UI.DISABLE_FIGHT_SCENE_UPDATE;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
CodeDefine.UI.DISABLE_FIGHT_SCENE_UPDATE = !value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("目标帧率")]
|
2023-10-19 15:00:19 +08:00
|
|
|
public int TargetFrameRate
|
|
|
|
|
{
|
|
|
|
|
get { return _targetFrameRate; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_targetFrameRate = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int _targetFrameRate = 60;
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("设置帧率")]
|
2023-10-19 15:00:19 +08:00
|
|
|
public void SetFps()
|
|
|
|
|
{
|
|
|
|
|
Application.targetFrameRate = _targetFrameRate;
|
|
|
|
|
}
|
2024-01-10 18:11:17 +08:00
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("目标分辨率")]
|
2024-01-10 18:11:17 +08:00
|
|
|
public int Resolution
|
|
|
|
|
{
|
|
|
|
|
get { return _resolution; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_resolution = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int _resolution = 0;
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("设置分辨率")]
|
2024-01-10 18:11:17 +08:00
|
|
|
public void SetResoulution()
|
|
|
|
|
{
|
|
|
|
|
PerformanceManager.SetResolution(_resolution);
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("启用特效")]
|
2023-10-19 15:00:19 +08:00
|
|
|
public bool EnableEffect
|
|
|
|
|
{
|
|
|
|
|
get { return _enableEffect; }
|
|
|
|
|
set { _enableEffect = value; }
|
|
|
|
|
}
|
|
|
|
|
private bool _enableEffect = true;
|
|
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("性能"), DisplayName("启用日志")]
|
2023-10-19 15:00:19 +08:00
|
|
|
public bool EnableLog
|
|
|
|
|
{
|
|
|
|
|
get { return DebugUtil.LogEnable; }
|
|
|
|
|
set { DebugUtil.LogEnable = value; }
|
|
|
|
|
}
|
2025-03-18 19:16:41 +08:00
|
|
|
|
|
|
|
|
[Category("性能"), DisplayName("启用后处理描边")]
|
|
|
|
|
public bool EnableOutline
|
|
|
|
|
{
|
|
|
|
|
get { return _enableOutline; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableOutline = value;
|
|
|
|
|
OutlineManager.instance.m_EnableOutline = _enableOutline;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableOutline = true;
|
|
|
|
|
|
2025-03-19 17:05:30 +08:00
|
|
|
[Category("性能"), DisplayName("启用法线外拓描边")]
|
|
|
|
|
public bool EnableMeshOutline
|
|
|
|
|
{
|
|
|
|
|
get { return AOTCodeDefine.ENABLE_MESH_OUTLINE; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
AOTCodeDefine.ENABLE_MESH_OUTLINE = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
#region 场景物件开关
|
2023-10-19 15:00:19 +08:00
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("场景物件开关"), DisplayName("CombinedRoot阴影开关")]
|
|
|
|
|
public bool EnableCombineRootCastShadow
|
2023-10-19 15:00:19 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableCombineRootCastShadow;
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
set
|
|
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
_enableCombineRootCastShadow = value;
|
|
|
|
|
var findObj = _FindObjInArt("CombinedRoot");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
for (int i = 0; i < findObj.transform.childCount; i++)
|
|
|
|
|
{
|
|
|
|
|
var child = findObj.transform.GetChild(i);
|
|
|
|
|
if (child == null) continue;
|
|
|
|
|
var meshRenderer = child.GetComponent<MeshRenderer>();
|
|
|
|
|
if (meshRenderer == null) continue;
|
|
|
|
|
meshRenderer.shadowCastingMode = _enableCombineRootCastShadow
|
|
|
|
|
? UnityEngine.Rendering.ShadowCastingMode.On
|
|
|
|
|
: UnityEngine.Rendering.ShadowCastingMode.Off;
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-18 18:23:34 +08:00
|
|
|
private bool _enableCombineRootCastShadow = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("CombinedRoot显示开关")]
|
|
|
|
|
public bool EnableCombineRootShow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableCombineRootShow;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableCombineRootShow = value;
|
|
|
|
|
var findObj = _FindObjInArt("CombinedRoot");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableCombineRootShow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableCombineRootShow = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("Ground显示开关")]
|
|
|
|
|
public bool EnableGroundShow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableGroundShow;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableGroundShow = value;
|
|
|
|
|
var findObj = _FindObjInArt("Ground");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableGroundShow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableGroundShow = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("Trees显示开关")]
|
|
|
|
|
public bool EnableTreesShow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableTreesShow;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableTreesShow = value;
|
|
|
|
|
var findObj = _FindObjInArt("Trees");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableTreesShow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableTreesShow = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("Grass01显示开关")]
|
|
|
|
|
public bool EnableGrass01Show
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableGrass01Show;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableGrass01Show = value;
|
|
|
|
|
var findObj = _FindObjInArt("Grass01");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableGrass01Show);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableGrass01Show = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("Grass02显示开关")]
|
|
|
|
|
public bool EnableGrass02Show
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableGrass02Show;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableGrass02Show = value;
|
|
|
|
|
var findObj = _FindObjInArt("Grass02");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableGrass02Show);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableGrass02Show = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("Effect显示开关")]
|
|
|
|
|
public bool EnableEffectShow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableEffectShow;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableEffectShow = value;
|
|
|
|
|
var findObj = _FindObjInArt("Effect");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableEffectShow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableEffectShow = true;
|
|
|
|
|
|
|
|
|
|
[Category("场景物件开关"), DisplayName("GlobalVolume显示开关")]
|
|
|
|
|
public bool GlobalVolumeEnable
|
2023-10-19 15:00:19 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _globalVolumeEnable;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_globalVolumeEnable = value;
|
2025-03-18 19:14:52 +08:00
|
|
|
var findObj = _FindObjInArt("Global Volume");
|
2025-03-18 18:23:34 +08:00
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_globalVolumeEnable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _globalVolumeEnable = true;
|
2025-03-19 11:57:46 +08:00
|
|
|
|
|
|
|
|
private GameObject _cacheObjRoot;
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("场景物件开关"), DisplayName("所有动态单位显示开关")]
|
|
|
|
|
public bool EnableAllUnitsShow
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableAllUnitsShow;
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
set
|
|
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
_enableAllUnitsShow = value;
|
2025-03-19 11:57:46 +08:00
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
_cacheObjRoot?.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var findObj = _FindObjInRoot("GameObjectFactoryRoot");
|
|
|
|
|
if (findObj == null) return;
|
|
|
|
|
findObj.SetActive(_enableAllUnitsShow);
|
|
|
|
|
_cacheObjRoot = findObj;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-03-18 18:23:34 +08:00
|
|
|
private bool _enableAllUnitsShow = true;
|
2023-12-14 14:50:29 +08:00
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
[Category("场景物件开关"), DisplayName("总阴影开关")]
|
|
|
|
|
public bool EnableShadowForAll
|
2023-12-14 14:50:29 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableShadowForAll;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_enableShadowForAll = value;
|
|
|
|
|
var allCameras = Camera.allCameras;
|
|
|
|
|
for (int i = 0; i < allCameras.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var camera = allCameras[i];
|
|
|
|
|
if (camera == null) continue;
|
|
|
|
|
var additionalCameraData = camera.GetComponent<UniversalAdditionalCameraData>();
|
|
|
|
|
if (additionalCameraData == null) continue;
|
|
|
|
|
if (additionalCameraData.renderType != CameraRenderType.Base) continue;
|
|
|
|
|
additionalCameraData.renderShadows = _enableShadowForAll;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _enableShadowForAll = true;
|
|
|
|
|
|
|
|
|
|
private List<bool> _oldRenderCache = new List<bool>();
|
|
|
|
|
private List<Camera> _oldCameraCache = new List<Camera>();
|
|
|
|
|
[Category("场景物件开关"), DisplayName("总渲染开关")]
|
|
|
|
|
public bool EnableAllRenderers
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _enableAllRenderers;
|
|
|
|
|
}
|
2023-12-14 14:50:29 +08:00
|
|
|
set
|
|
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
_enableAllRenderers = value;
|
|
|
|
|
if (!_enableAllRenderers)
|
|
|
|
|
{
|
|
|
|
|
var allCameras = Camera.allCameras;
|
|
|
|
|
_oldRenderCache.Clear();
|
|
|
|
|
_oldCameraCache.Clear();
|
|
|
|
|
for (int i = 0; i < allCameras.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
var camera = allCameras[i];
|
|
|
|
|
if (camera == null) continue;
|
|
|
|
|
_oldRenderCache.Add(camera.enabled);
|
|
|
|
|
_oldCameraCache.Add(camera);
|
|
|
|
|
|
|
|
|
|
camera.enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2023-12-14 14:50:29 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
for (int i = 0; i < _oldCameraCache.Count; i++)
|
2023-12-14 14:50:29 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
var camera = _oldCameraCache[i];
|
|
|
|
|
if (camera == null) continue;
|
|
|
|
|
camera.enabled = _oldRenderCache[i];
|
2023-12-14 14:50:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-18 18:23:34 +08:00
|
|
|
private bool _enableAllRenderers = true;
|
2023-12-14 14:50:29 +08:00
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
private GameObject _FindObjInRoot(string objName)
|
2024-12-31 12:50:42 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
var findObj = GameObject.Find(objName);
|
|
|
|
|
if (findObj == null)
|
2024-12-31 12:50:42 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
Debug.LogError("场景中没有" + objName);
|
|
|
|
|
return null;
|
2024-12-31 12:50:42 +08:00
|
|
|
}
|
2025-03-18 18:23:34 +08:00
|
|
|
return findObj;
|
2024-12-31 12:50:42 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-18 18:23:34 +08:00
|
|
|
private GameObject _FindObjInArt(string objName)
|
2024-12-31 12:50:42 +08:00
|
|
|
{
|
2025-03-18 18:23:34 +08:00
|
|
|
var artObj = GameObject.Find("Art");
|
|
|
|
|
if (artObj == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("Art对象不存在");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var obj = artObj.transform.Find(objName);
|
|
|
|
|
if (obj == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("Art对象下没有" + objName);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return obj.gameObject;
|
2024-12-31 12:50:42 +08:00
|
|
|
}
|
2025-03-18 18:23:34 +08:00
|
|
|
|
|
|
|
|
#endregion
|
2023-12-14 14:50:29 +08:00
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
[Category("性能"),DisplayName("渲图")]
|
|
|
|
|
public void RenderImg()
|
|
|
|
|
{
|
|
|
|
|
// 渲图
|
|
|
|
|
var renderTexture = new RenderTexture(1920, 1080, 24);
|
|
|
|
|
var additionalCameraData = CameraManager.Instance.UICamera.GetComponent<UniversalAdditionalCameraData>();
|
|
|
|
|
additionalCameraData.renderType = CameraRenderType.Base;
|
|
|
|
|
CameraManager.Instance.UICamera.targetTexture = renderTexture;
|
|
|
|
|
CameraManager.Instance.UICamera.Render();
|
|
|
|
|
additionalCameraData.renderType = CameraRenderType.Overlay;
|
|
|
|
|
CameraManager.Instance.UICamera.targetTexture = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RenderTexture.active = renderTexture;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存到本地
|
|
|
|
|
var texture2D = new Texture2D(RenderTexture.active.width, RenderTexture.active.height, TextureFormat.RGB24, false);
|
|
|
|
|
texture2D.ReadPixels(new Rect(0, 0, RenderTexture.active.width, RenderTexture.active.height), 0, 0);
|
|
|
|
|
texture2D.Apply();
|
|
|
|
|
var bytes = texture2D.EncodeToPNG();
|
|
|
|
|
var path = Application.dataPath + "/" + "render.png";
|
|
|
|
|
System.IO.File.WriteAllBytes(path, bytes);
|
|
|
|
|
AssetDatabase.Refresh();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|