尝试从不同层渲染粒子以在我的 UI 上显示它

问题描述

我正在尝试在我的 UI 上显示粒子效果。然后我看到了这篇文章Unity Particle Effects On Canvas 而且我按照每一步操作,但是由于某种原因,当我点击播放时,画布上没有显示粒子。

[我的粒子相机组件][1] [我的层次][2]

我只是按照帖子中显示的步骤操作,所以我的脚本基本相同:

    using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Particle_Camera_Script : MonoBehavIoUr
{
    // Here reference the camera component of the particles camera
    [Serializefield] private Camera particlesCamera;

    // Adjust the resolution in pixels
    [Serializefield] private Vector2Int imageResolution = new Vector2Int(256,256);

    // Reference the RawImage in your UI
    [Serializefield] private RawImage targetimage;

    private RenderTexture renderTexture;

    private void Awake()
    {
        if (!particlesCamera) particlesCamera = GetComponent<Camera>();

        renderTexture = new RenderTexture(imageResolution.x,imageResolution.y,32);
        particlesCamera.targetTexture = renderTexture;

        targetimage.texture = renderTexture;
    }
}

任何帮助将不胜感激。谢谢您阅读此篇。 [1]:https://i.stack.imgur.com/alNAL.png [2]:https://i.stack.imgur.com/XtbtH.png

解决方法

我尝试了@Iggy 方法,它似乎工作正常。我只需要下载一个包,然后我就可以开始了。 https://github.com/mob-sakai/ParticleEffectForUGUI

我不知道为什么这篇文章会被讨厌,但是不喜欢的人至少可以告诉我原因,这样我至少可以改进。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...