feat(gameplay): 更新单位属性和材质配置 - 调整多个单位的基础生命值和攻击力数值平衡 - 修改CoreBattleGround材质的纹理缩放比例 - 更新地砖材质颜色为白色 - 优化纹理资源设置,调整最大纹理尺寸并添加PlayableAds平台支持 - 修复弓箭手技能目标查找逻辑,改用统一的敌人检测方法 - 为水晶矿添加中立阵营设置和光球视觉效果同步 - 调整预制体中的全局缩放参数 - 为狼人和石巨人添加NavMeshAgent组件支持 - 优化水晶矿血条显示位置计算方式 ```
77 lines
2.4 KiB
C#
77 lines
2.4 KiB
C#
using UnityEngine;
|
|
|
|
[ExecuteAlways]
|
|
public class AdjustableGlowOrb : MonoBehaviour
|
|
{
|
|
[SerializeField] private Color glowColor = new Color(0.1f, 0.65f, 1f, 1f);
|
|
[SerializeField, Min(0f)] private float emissionIntensity = 2.5f;
|
|
[SerializeField, Range(0f, 1f)] private float haloAlpha = 0.25f;
|
|
[SerializeField] private Renderer targetRenderer;
|
|
[Tooltip("光晕等附属渲染器,留空时自动收集子级(排除主体球)")]
|
|
[SerializeField] private Renderer[] haloRenderers;
|
|
|
|
private MaterialPropertyBlock propertyBlock;
|
|
|
|
private void OnEnable()
|
|
{
|
|
ApplyVisuals();
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
ApplyVisuals();
|
|
}
|
|
|
|
public void SetGlowColor(Color color)
|
|
{
|
|
glowColor = color;
|
|
ApplyVisuals();
|
|
}
|
|
|
|
public Color GetGlowColor() => glowColor;
|
|
|
|
private void ApplyVisuals()
|
|
{
|
|
if (targetRenderer == null)
|
|
{
|
|
targetRenderer = GetComponent<Renderer>();
|
|
}
|
|
|
|
if (haloRenderers == null || haloRenderers.Length == 0)
|
|
{
|
|
haloRenderers = GetComponentsInChildren<Renderer>(true);
|
|
for (int i = 0; i < haloRenderers.Length; i++)
|
|
{
|
|
if (haloRenderers[i] == targetRenderer)
|
|
{
|
|
haloRenderers[i] = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (targetRenderer != null)
|
|
{
|
|
propertyBlock ??= new MaterialPropertyBlock();
|
|
targetRenderer.GetPropertyBlock(propertyBlock);
|
|
Color emission = glowColor * emissionIntensity;
|
|
propertyBlock.SetColor("_BaseColor", glowColor);
|
|
propertyBlock.SetColor("_Color", glowColor);
|
|
propertyBlock.SetColor("_EmissionColor", emission);
|
|
targetRenderer.SetPropertyBlock(propertyBlock);
|
|
}
|
|
|
|
if (haloRenderers == null) return;
|
|
propertyBlock ??= new MaterialPropertyBlock();
|
|
Color haloTint = new Color(glowColor.r, glowColor.g, glowColor.b, haloAlpha);
|
|
foreach (Renderer halo in haloRenderers)
|
|
{
|
|
if (halo == null) continue;
|
|
halo.GetPropertyBlock(propertyBlock);
|
|
// Legacy Shaders/Particles/Additive 用 _TintColor 作为颜色入口
|
|
propertyBlock.SetColor("_TintColor", haloTint);
|
|
propertyBlock.SetColor("_Color", haloTint);
|
|
halo.SetPropertyBlock(propertyBlock);
|
|
}
|
|
}
|
|
}
|