我已从资源商店下载了FPS构造函数,但它是为较旧的Unity API而制作的。我试图修复它,我大多理解它,但我遇到了一个C#脚本(我不熟悉C#)并且不知道如何修复它! 这是完整的脚本:
using UnityEngine;
using System.Collections;
public class LightningBolt : MonoBehaviour
{
public Transform target;
public int zigs = 100;
public float speed = 1f;
public float scale = 1f;
public Light endLight;
[HideInInspector] public bool emits = false;
Perlin noise;
float oneOverZigs;
private Particle[] particles;
void Start()
{
oneOverZigs = 1f / (float)zigs;
particleEmitter.emit = false;
particleEmitter.Emit(zigs);
particles = particleEmitter.particles;
}
void Update ()
{
if(target == null)
return;
if(!emits){
return;
}
endLight.intensity = 1;
if (noise == null)
noise = new Perlin();
float timex = Time.time * speed * 0.1365143f;
float timey = Time.time * speed * 1.21688f;
float timez = Time.time * speed * 2.5564f;
for (int i=0; i < particles.Length; i++)
{
Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
Vector3 offset = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
noise.Noise(timey + position.x, timey + position.y, timey + position.z),
noise.Noise(timez + position.x, timez + position.y, timez + position.z));
position += (offset * scale * ((float)i * oneOverZigs));
particles[i].position = position;
particles[i].color = Color.white;
particles[i].energy = 1f;
}
particleEmitter.particles = particles;
if (particleEmitter.particleCount >= 2)
{
if (endLight)
endLight.transform.position = particles[particles.Length - 1].position;
}
}
void EmitCharge (bool s) {
emits = s;
endLight.intensity = 0;
}
/* C
*/
void Target (Transform t) {
target = t;
}
}
如果您没有完整地看到它 - 复制粘贴的说明:
Assets / Plugins / FPS Constructor V1 / Demo Assets / Weapons / PlasmaBeam / LightningBolt.cs(24,19):错误CS1061:类型
UnityEngine.Component
不包含emit
的定义且没有扩展名可以找到emit
类型的方法UnityEngine.Component
。你错过了装配参考吗?
资产/插件/ FPS构造函数V1 /演示资产/武器/ PlasmaBeam / LightningBolt.cs(26,19):错误CS1061:类型
UnityEngine.Component
不包含Emit
的定义且没有扩展名可以找到Emit
类型的方法UnityEngine.Component
。你错过了装配参考吗?
Assets / Plugins / FPS Constructor V1 / Demo Assets / Weapons / PlasmaBeam / LightningBolt.cs(27,31):错误CS1061:类型
UnityEngine.Component
不包含particles
的定义且没有扩展名可以找到particles
类型的方法UnityEngine.Component
。你错过了装配参考吗?
资产/插件/ FPS构造函数V1 /演示资产/武器/等离子束/ LightningBolt.cs(58,19):错误CS1061:类型
UnityEngine.Component
不包含particles
的定义,不可以找到类型为particles
的扩展方法UnityEngine.Component
。你错过了装配参考吗?
资产/插件/ FPS构造函数V1 /演示资产/武器/等离子束/ LightningBolt.cs(60,23):错误CS1061:类型
UnityEngine.Component
不包含particleCount
的定义,不可以找到类型为particleCount
的扩展方法UnityEngine.Component
。你错过了装配参考吗?
答案 0 :(得分:0)
在5.6中删除了Component.particleEmitter。您应该使用GetComponent来获取ParticleEmitter组件。添加这些行,它应该更好:
ParticleEmitter particleEmitter;
void Start()
{
particleEmitter = GetComponent<ParticleEmitter>();
如果其他任何内容无效,请告诉我!如果您运行Unity脚本升级的东西,可能会有!