unity工具类篇 网格特效渲染适配
Posted 其子昱舟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了unity工具类篇 网格特效渲染适配相关的知识,希望对你有一定的参考价值。
一、渲染脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 网格特效渲染
public class UIGridRenderingScale : MonoBehaviour
private List<ScaleData> scaleDatas = new List<ScaleData>();
private void Awake()
foreach (ParticleSystem p in transform.GetComponentsInChildren<ParticleSystem>(true))
scaleDatas.Add(new ScaleData() transform = p.transform, beginScale = p.transform.localScale);
// Start is called before the first frame update
void Start()
float designWidth = 1080;
float designHeight = 1920;
float designScale = designWidth / designHeight;
float scaleRate = (float)Screen.width / (float)Screen.height;
foreach (ScaleData scale in scaleDatas)
if (scale.transform != null)
if (scaleRate < designScale)
float scaleFactor = scaleRate / designScale;
scale.transform.localScale = scale.beginScale * scaleFactor;
else
scale.transform.localScale = scale.beginScale;
#if UNITY_EDITOR
void Update()
Start();
#endif
class ScaleData
public Transform transform;
public Vector3 beginScale = Vector3.one;
二、使用方式
直接挂载在对应的渲染器上面即可
以上是关于unity工具类篇 网格特效渲染适配的主要内容,如果未能解决你的问题,请参考以下文章