Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Accessing the particle rendermode?

Discussion in 'Scripting' started by mumbot, Nov 1, 2016.

  1. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    Hey all iv got a quick question. Im trying to change the particle rendermode in c#. How can i do this?

    What i currently have in code:
     
  2. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    When you run this code and look at the particle Renderer in the Inspector do you see it change to HorizontalBillBoard?
    What error are you getting. It seems like the code you posted should work

    After looking into it, it seems ParticleRenderer is legacy code and obsolete.. what you want is ParticleSystemRenderer:
    https://docs.unity3d.com/ScriptReference/ParticleSystemRenderer.html

    I made an Empty GameObject, made a child particle system to it and attached this code:
    Code (CSharp):
    1. using UnityEngine.UI;
    2. using System.Collections.Generic;
    3.  
    4. public class Bricks : MonoBehaviour
    5. {
    6.     void Start()
    7.     {
    8.         ParticleSystemRenderer pr = GetComponentInChildren<ParticleSystemRenderer>();
    9.         pr.renderMode = ParticleSystemRenderMode.HorizontalBillboard;
    10.        
    11.     }
    12. }
    And it switched my particles to HorizontalBillboard as expected.
     
    Last edited: Nov 1, 2016
  3. mumbot

    mumbot

    Joined:
    Oct 19, 2012
    Posts:
    86
    Thanks man. That worked!