• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Hollowayinc · Jun 17, 2020 at 09:47 AM · particlesparticlesystemparticle systemstars

Particle System stars script command calls are obsolete. How do I fix this or call the particles the right way. I use unity 2018.3 right now.

using System; using System.Collections; using System.Collections.Generic; using UnityEngine.ParticleSystemModule using UnityEngine; /* using UnityEngine; using System.Collections;

public class ExampleClass : MonoBehaviour { private ParticleSystem ps; public float hSliderValue = 1.0F;

 void Start()
 {
     ps = GetComponent<ParticleSystem>();
 }

 void Update()
 {
     var main = ps.main;
     main.startSize = hSliderValue;
 }

 void OnGUI()
 {
     hSliderValue = GUI.HorizontalSlider(new Rect(25, 45, 100, 30), hSliderValue, 0.0F, 10.0F);
 }

}*/ public class InfiniteStarfield : MonoBehaviour {

 private ParticleSystem.Particle[] points;
 public ParticleSystem.MinMaxCurve startSize;
 public float hSliderValue = 8.0F;
 public ParticleSystem.MinMaxGradient startColor;
 public float hSliderValueR = 0.0F;
 public float hSliderValueG = 0.0F;
 public float hSliderValueB = 0.0F;
 public float hSliderValueA = 1.0F;

 private ParticleSystem ps;
 private Transform tx;
 public int starsMax = 600;
 public float starSize = .35f;
 public float starDistance = 60f;
 private float starDistanceSqr = 10f;
 private float starClipDistnacesqr = 15f;
 public Color starColor;
 
 // Start is called before the first frame update
 void Start()
 {
     GetComponent<ParticleSystem>().SetParticles(points, points.Length);
     tx = GetComponent<Transform>();
     ps = tx.GetComponent<ParticleSystem>();
     starDistanceSqr = starDistance * starDistance;
     starClipDistnacesqr = starClipDistnacesqr * starClipDistnacesqr;
 }

 // Update is called once per frame
 void Update()
 {

     var main = ps.main;
      main.startSize = hSliderValue;
     main.startColor = new Color(hSliderValueR, hSliderValueG, hSliderValueB, hSliderValueA);
     ps.SetParticles(points, points.Length);

     if (ps == null) CreateStars();
      
      for (int i = 0; i < starsMax; i++)
      {
           if ((points[i].position - tx.position).sqrMagnitude > starDistanceSqr)
          {
             points[i].position = (UnityEngine.Random.insideUnitSphere * starDistanceSqr) + tx.position;
              points[i].color = new Color(1, 1, 1, 1);
          }
         if ((points[i].position - tx.position).sqrMagnitude <= starDistanceSqr)
         {
             float cap = (points[i].position - tx.position).sqrMagnitude / starClipDistnacesqr;
         }
      }
     GetComponent<ParticleSystem>().SetParticles(points, points.Length);
 }

/* void OnGUI() { hSliderValue = GUI.HorizontalSlider(new Rect(25, 45, 100, 30), hSliderValue, 0.0F, 10.0F); GUI.Label(new Rect(25, 40, 100, 30), "Red"); GUI.Label(new Rect(25, 70, 100, 30), "Green"); GUI.Label(new Rect(25, 100, 100, 30), "Blue"); GUI.Label(new Rect(25, 130, 100, 30), "Alpha");

     hSliderValueR = GUI.HorizontalSlider(new Rect(95, 45, 100, 30), hSliderValueR, 0.0F, 1.0F);
     hSliderValueG = GUI.HorizontalSlider(new Rect(95, 75, 100, 30), hSliderValueG, 0.0F, 1.0F);
     hSliderValueB = GUI.HorizontalSlider(new Rect(95, 105, 100, 30), hSliderValueB, 0.0F, 1.0F);
     hSliderValueA = GUI.HorizontalSlider(new Rect(95, 135, 100, 30), hSliderValueA, 0.0F, 1.0F);
 }
  • private void CreateStars() { points = new ParticleSystem.[starsMax]; for (int i = 0; i < starsMax; i++) { points[i].position = UnityEngine.Random.insideUnitSphere * starDistanceSqr + tx.position; points[i].size = starSize; points[i].color = new Color(1, 1, 1, 1); } } } alt text

starfieldquestion.jpg (167.6 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image karl_jones ♦♦ · Jun 17, 2020 at 05:31 PM 0
Share

It tells you how to fix the problems in the obsolete message.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

213 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Particle Field not emitting at all 1 Answer

ParticleSystem collidesWith 2 Answers

How do I set the statColor of a particle system through script 2 Answers

Particle system only playing when visible 0 Answers

Particle System Particles Not Following Rotation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges