本文整理汇总了C#中ParticleSystem.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# ParticleSystem.GetComponent方法的具体用法?C# ParticleSystem.GetComponent怎么用?C# ParticleSystem.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
/// <summary>
/// Initialises the script
/// </summary>
void Start()
{
m_particles = GetComponent<ParticleSystem> ();
m_particles.GetComponent<Renderer>().sortingLayerName = "World";
m_particles.GetComponent<Renderer>().sortingOrder = 4;
m_rigidBody = transform.parent.GetComponent<Rigidbody>();
}
示例2: Start
void Start()
{
ps = GetComponent<ParticleSystem>();
ps.GetComponent<Renderer>().sortingLayerName = sortingLayer;
ps.GetComponent<Renderer>().sortingOrder = sortingOrder;
if (killAfterLifetime) StartCoroutine("Kill");
if (transform.parent == null)
transform.parent = GameObject.Find("Slots").transform;
}
示例3: Awake
private void Awake()
{
m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent<ParticleSystem>();
m_ExplosionAudio = m_ExplosionParticles.GetComponent<AudioSource>();
m_ExplosionParticles.gameObject.SetActive(false); //Always better to keep particle systems in memory and work with them so the GC does not kick in and there are no spikes in performance
}
示例4: Awake
private void Awake()
{
m_ExplosionParticles = Instantiate(m_ExplosionPrefab).GetComponent<ParticleSystem>();
m_ExplosionAudio = m_ExplosionParticles.GetComponent<AudioSource>();
m_ExplosionParticles.gameObject.SetActive(false);
}
示例5: SetParticleSystemScale
static public void SetParticleSystemScale(ParticleSystem particleSystem, float scale)
{
particleSystem.startLifetime *= scale;
particleSystem.startSize *= scale;
if (particleSystem.GetComponent<ParticleEmitter>() != null)
{
particleSystem.GetComponent<ParticleEmitter>().minSize *= scale;
particleSystem.GetComponent<ParticleEmitter>().maxSize *= scale;
}
if (particleSystem.GetComponent<ConstantForce>() != null)
{
particleSystem.GetComponent<ConstantForce>().force *= scale;
}
}
示例6: Initialize
protected bool Initialize() {
// initialize members
if (_transform == null) {
_transform = transform;
}
if (_particleSystem == null) {
_particleSystem = GetComponent<ParticleSystem>();
if (_particleSystem == null) {
return false;
}
// automatically set material to UI/Particles/Hidden shader, and get previous texture
ParticleSystemRenderer renderer = _particleSystem.GetComponent<ParticleSystemRenderer>();
if (renderer == null) {
renderer = _particleSystem.gameObject.AddComponent<ParticleSystemRenderer>();
}
Material currentMaterial = renderer.sharedMaterial;
if (currentMaterial && currentMaterial.HasProperty("_MainTex")) {
particleTexture = currentMaterial.mainTexture;
}
Material material = new Material(Shader.Find("UI/Particles/Hidden")); // TODO - You should create this discard shader
if (Application.isPlaying) {
renderer.material = material;
}
#if UNITY_EDITOR
else {
material.hideFlags = HideFlags.DontSave;
renderer.sharedMaterial = material;
}
#endif
// automatically set scaling
_particleSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
_particles = null;
}
if (_particles == null) {
_particles = new ParticleSystem.Particle[_particleSystem.maxParticles];
}
// prepare uvs
if (particleTexture) {
_uv = new Vector4(0, 0, 1, 1);
} else if (particleSprite) {
_uv = UnityEngine.Sprites.DataUtility.GetOuterUV(particleSprite);
}
// prepare texture sheet animation
_textureSheetAnimation = _particleSystem.textureSheetAnimation;
_textureSheetAnimationFrames = 0;
_textureSheedAnimationFrameSize = Vector2.zero;
if (_textureSheetAnimation.enabled) {
_textureSheetAnimationFrames = _textureSheetAnimation.numTilesX * _textureSheetAnimation.numTilesY;
_textureSheedAnimationFrameSize = new Vector2(1f / _textureSheetAnimation.numTilesX, 1f / _textureSheetAnimation.numTilesY);
}
return true;
}
示例7: DriverSetup
// Use this for initialization
public override void DriverSetup()
{
_mngSystem = gobSystemManager.GetComponent<ParticleManager>();
sysMySys = gameObject.GetComponent<ParticleSystem>() as ParticleSystem;
_mngSystem.RegisterSystem(sysMySys, this);
renSystemRenderer = sysMySys.GetComponent<Renderer>() as Renderer;
AdditionalSetup();
}
示例8: Start
void Start()
{
go_Water = GameObject.Find ("GO_Water");
MPI_LMScript = GameObject.Find ("MPI_Level_Manager").GetComponent<MPI_Level_Manager>();
KrakenScript = GameObject.FindGameObjectWithTag ("Kraken").GetComponent<TL_KrakenScript>();
Water_Particles = GetComponentInChildren<ParticleSystem>();
Water_Particles.GetComponent<ParticleSystem>().Play();
fl_AttackCooldown = 2f + Time.realtimeSinceStartup;
}
示例9: Init
public void Init(Vector3 pos, int maxParticles, Color color)
{
transform.localPosition = pos + Vector3.up * 0.25f;
particles = GetComponent<ParticleSystem>();
particles.GetComponent<Renderer>().sortingLayerName = "Ui";
particles.startColor = color;
particles.Emit(maxParticles);
Destroy(gameObject, 1f);
}
示例10: Init
public void Init(Vector3 startPos, Vector3 endPos, float duration, int maxParticles, Color color)
{
startPos += Vector3.up * 0.25f;
particles = GetComponent<ParticleSystem>();
particles.GetComponent<Renderer>().sortingLayerName = "Ui";
particles.startColor = color;
particles.Emit(maxParticles);
StartCoroutine(Move(startPos, endPos, duration));
}
示例11: StartShooting
public void StartShooting(Transform targetPos = null)
{
isShooting = true;
GameObject muzzleFlashObject = (GameObject.Instantiate(muzzleFlashPrefab, muzzleFlashPlacement.transform.position, muzzleFlashPrefab.transform.rotation) as GameObject);
muzzleFlashObject.transform.parent = muzzleFlashPlacement.transform;
muzzleFlash = muzzleFlashObject.GetComponent<ParticleSystem>();
if (muzzleFlash != null)
muzzleFlash.GetComponent<ParticleSystem>().Play();
}
示例12: initializeRest
override protected void initializeRest() {
jpm = (JetpackManager) objectsManager;
canBeMagnetized = false;
booster = transform.Find("Booster").GetComponent<ParticleSystem>();
boosterSound = booster.GetComponent<AudioSource>();
minBoosterSpeed = jpm.minBoosterAmount;
maxBoosterSpeed = jpm.maxBoosterAmonut;
decreaseBase = jpm.boosterSpeedDecreaseBase;
decreasePerTime = jpm.boosterSpeedDecreasePerTime;
delay = jpm.delayAfterMove;
}
示例13: Start
// Use this for initialization
void Start () {
particles = GetComponent<ParticleSystem>();
mat = particles.GetComponent<Renderer>().material;
if (combos > 1)
mat.mainTexture = combo_textures[combos-2];
else
{
int i = (Mathf.FloorToInt(Random.value * 10))%3;
mat.mainTexture = cheering[i];
}
Destroy(gameObject, 1f);
}
示例14: Awake
void Awake ()
{
particle = gameObject.GetComponent<ParticleSystem>();
if(particle != null)
particle.GetComponent<Renderer>().sharedMaterial.renderQueue = RenderQStartNum;
if( particle == null )
{
ParticleRenderer renderer = gameObject.GetComponent<ParticleRenderer>();
if( renderer != null )
renderer.sharedMaterial.renderQueue = RenderQStartNum;
}
}
示例15: destroyStuff
public void destroyStuff()
{
myExplosion = (ParticleSystem) GameObject.Instantiate((Object)explosion);
myExplosion.name = "destroyedPart";
myExplosion.transform.position = transform.position;
myExplosion.GetComponent<HandleExplosion>().startUp();
startedPlaying= true;
Destroy (redPartHealthBar);
Destroy (greenPartHealthBar);
Destroy (blackPartHealthBar);
Destroy (triggerArea);
Destroy (gameObject);
//Destroy (myExplosion);
}