粒子系统附加到游戏对象时为粉红色
Particle System pink when attached to a GameObject
我正在研究统一粒子系统。
我创建了一个新项目和一个空对象,然后向其中添加了粒子系统。由于某种原因,它无法正常工作,您可以查看附加的图像以查看发生了什么...
Unity粒子系统粉色方块:
很可能你没有为你的粒子select编辑material,或者你之前的select离子被擦除(例如通过移动资产)。粉红色是 Unity 指示获取粒子系统 material 时出现问题的方式。您可以通过 select 一个新的,或重新 select 您以前使用的粒子纹理来解决这个问题。
在粒子对象检查器的底部周围应该有一个名为 renderer 的部分,您可以在其中 select 一个新的 material。这是粒子系统中的最后一个选项卡。
现在您可以通过单击渲染器中的 material 字段并找到默认粒子来解决此问题。如果需要,您也可以使用其他 material。
如果您通过脚本创建了粒子系统,您将不得不看到@Programmers 的回答,但它仍然会归结为缺少 material。
由于您创建粒子的方式,问题是 缺失 material。
创建粒子系统有两种种方法:
1.Create empty GameObject, select 然后转到 Component --> Effects 并将 粒子系统 组件添加到该空游戏对象。这就是您创建当前粒子系统的方式。
如果您使用方法 #1 创建粒子系统,Unity 将 不会 因此将 material 附加到粒子系统使它变成粉红色。您必须创建一个新的 Material,将着色器更改为 "Particles/Alpha Blended Premultiply" 并使用 "Default-Particle" 作为纹理,使粒子看起来像默认 material。
你也可以只使用"Default-Material"的粒子系统,但你不能修改它。
2。通过转到 GameObject 创建粒子 ---> Effects -- -> 粒子系统.
如果您使用方法 #2 创建粒子系统,Unity 将 创建新的游戏对象,附加一个粒子系统和 还有一个material给它。
始终通过转到 GameObject ---> Effects ---> [=34= 创建你的 material ]粒子系统。它会节省你一些时间。
简单的解决方案是删除当前的粒子 GameObject,通过转到 GameObject ---> Effects 创建一个新的 GameObject --> -> 粒子系统代替#1.
中描述的方法
如果您需要从代码创建粒子系统,那么按照我在方法#1中所说的,但是通过脚本。方法如下:
void Start()
{
createParticleSys();
}
void createParticleSys()
{
//Create GameObject to hold the Particle System
GameObject psObj = new GameObject("Particle System");
//Add Particle System to it
ParticleSystem ps = psObj.AddComponent<ParticleSystem>();
//Assign material to the particle renderer
ps.GetComponent<Renderer>().material = createParticleMaterial();
}
Material createParticleMaterial()
{
//Create Particle Shader
Shader particleShder = Shader.Find("Particles/Alpha Blended Premultiply");
//Create new Particle Material
Material particleMat = new Material(particleShder);
Texture particleTexture = null;
//Find the default "Default-Particle" Texture
foreach (Texture pText in Resources.FindObjectsOfTypeAll<Texture>())
if (pText.name == "Default-Particle")
particleTexture = pText;
//Add the particle "Default-Particle" Texture to the material
particleMat.mainTexture = particleTexture;
return particleMat;
}
我正在研究统一粒子系统。
我创建了一个新项目和一个空对象,然后向其中添加了粒子系统。由于某种原因,它无法正常工作,您可以查看附加的图像以查看发生了什么...
Unity粒子系统粉色方块:
很可能你没有为你的粒子select编辑material,或者你之前的select离子被擦除(例如通过移动资产)。粉红色是 Unity 指示获取粒子系统 material 时出现问题的方式。您可以通过 select 一个新的,或重新 select 您以前使用的粒子纹理来解决这个问题。
在粒子对象检查器的底部周围应该有一个名为 renderer 的部分,您可以在其中 select 一个新的 material。这是粒子系统中的最后一个选项卡。
现在您可以通过单击渲染器中的 material 字段并找到默认粒子来解决此问题。如果需要,您也可以使用其他 material。
如果您通过脚本创建了粒子系统,您将不得不看到@Programmers 的回答,但它仍然会归结为缺少 material。
由于您创建粒子的方式,问题是 缺失 material。
创建粒子系统有两种种方法:
1.Create empty GameObject, select 然后转到 Component --> Effects 并将 粒子系统 组件添加到该空游戏对象。这就是您创建当前粒子系统的方式。
如果您使用方法 #1 创建粒子系统,Unity 将 不会 因此将 material 附加到粒子系统使它变成粉红色。您必须创建一个新的 Material,将着色器更改为 "Particles/Alpha Blended Premultiply" 并使用 "Default-Particle" 作为纹理,使粒子看起来像默认 material。
你也可以只使用"Default-Material"的粒子系统,但你不能修改它。
2。通过转到 GameObject 创建粒子 ---> Effects -- -> 粒子系统.
如果您使用方法 #2 创建粒子系统,Unity 将 创建新的游戏对象,附加一个粒子系统和 还有一个material给它。
始终通过转到 GameObject ---> Effects ---> [=34= 创建你的 material ]粒子系统。它会节省你一些时间。
简单的解决方案是删除当前的粒子 GameObject,通过转到 GameObject ---> Effects 创建一个新的 GameObject --> -> 粒子系统代替#1.
中描述的方法如果您需要从代码创建粒子系统,那么按照我在方法#1中所说的,但是通过脚本。方法如下:
void Start()
{
createParticleSys();
}
void createParticleSys()
{
//Create GameObject to hold the Particle System
GameObject psObj = new GameObject("Particle System");
//Add Particle System to it
ParticleSystem ps = psObj.AddComponent<ParticleSystem>();
//Assign material to the particle renderer
ps.GetComponent<Renderer>().material = createParticleMaterial();
}
Material createParticleMaterial()
{
//Create Particle Shader
Shader particleShder = Shader.Find("Particles/Alpha Blended Premultiply");
//Create new Particle Material
Material particleMat = new Material(particleShder);
Texture particleTexture = null;
//Find the default "Default-Particle" Texture
foreach (Texture pText in Resources.FindObjectsOfTypeAll<Texture>())
if (pText.name == "Default-Particle")
particleTexture = pText;
//Add the particle "Default-Particle" Texture to the material
particleMat.mainTexture = particleTexture;
return particleMat;
}