Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by Babilinski · Nov 06, 2011 at 01:43 AM · c#errorparticlesconvert

Particle circle HELP

I use c sharp but I wanted to use the code from http://www.smokymonkeys.com/kyrill/ I converted java to c# and I don't understand how get rid of these few errors, can you guy take a look and see what might be causing them?

  using UnityEngine; using System.Collections;
 [ExecuteInEditMode]
 
 public class rings : MonoBehaviour {
 bool emit = true;
 float range = 1.0f;
 int particleCount = 16;
 float particleSize = 1.0f;
 float rotationSpeed = 0.5f;
 Color particleColor = Color.white;
 LayerMask layerMask = -1;
 float castMaxDistance = Mathf.Infinity;
 
 private int oldParticleCount; private ParticleEmitter emitter; private Particle[] particles;
 
 private float rot;
 
 private Vector3 center; private Vector3 pos; private RaycastHit hit;
 
 private Transform myTransform;
 
  
     
 void Awake (){
 emitter = gameObject.GetComponent();
 if (!emitter) {
             
 gameObject.AddComponent<EllipsoidParticleEmitter>();
 emitter = gameObject.GetComponent();
 } 
 emitter.emit = false;
 emitter.ClearParticles();
 emitter.useWorldSpace = true;
 createParticlesAry();
 
 myTransform = transform;
 }
 
 private void createParticlesAry (){
 if (particleCount < 0) {particleCount = 0;
 } 
 particles = new Particle[particleCount];
 oldParticleCount = particleCount;
     }
 
 private void setParticlesCount (){
 if (!particles || (oldParticleCount != particleCount)){
             createParticlesAry(); } }
 
 void Update (){
 setParticlesCount();
 emitter.ClearParticles();
 
 if (emit) {
     int i;
     float radian;
     float offsetY;
     Vector3 center;
     Vector3 pos;
     RaycastHit hit;
             
     center = myTransform.position;
     rot += Time.deltaTime *rotationSpeed;
     offsetY = particleSize /2;
     for (i = 0; i < particleCount; i++) {
         radian = Mathf.PI *(i /(particleCount *0.5f)) +rot;
         pos.x = range *Mathf.Cos(radian) +center.x;
         pos.y = center.y;
         pos.z = range *Mathf.Sin(radian) +center.z;
         if (Physics.Raycast(pos, -myTransform.up, out hit, castMaxDistance, layerMask)) {
             pos.y = hit.point.y +offsetY;
         }
         Debug.DrawRay(pos, myTransform.up *hit.distance, Color.red);
 
         particles[i].position = pos;
         particles[i].color = particleColor;
         particles[i].size = particleSize;
         particles[i].energy = 1.0f;
         particles[i].velocity = myTransform.up;
     }
 
     emitter.particles = particles;
 }
 }
 }

The errors that im getting are:

Assets/rings.cs(25,22): error CS0411: The type arguments for method UnityEngine.GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly > Assets/rings.cs(28,25): error CS0246: The type or namespace name EllipsoidParticleEmitter' could not be found. Are you missing a using directive or an assembly reference?

Assets/rings.cs(29,22): error CS0411: The type arguments for method UnityEngine.GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly > Assets/rings.cs(47,5): error CS1955: The member rings.particles' cannot be used as method or delegate

Please help

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by dannyskim · Nov 07, 2011 at 06:27 PM

The errors seem pretty self explanatory to me. For GetComponent, you're not passing in any kind of argument when you set the value in the Awake(). It's basically asking you, what are you looking for? It may work in Javascript, but it doesn't work in C# because C# requires much more strict typecasting. In Javascript, you typically are able to dynamically typecast because the compiler will sort it out for you, but that's not the case in C#. Find exactly what you are looking for and declare the type when you're utilizing GetComponent in C#.

I could be wrong, but I am not personally aware of an EllipsoidParticleEmitter component anywhere in the UnityEngine. There's a ParticleEmitter component though, so I'm not quite sure what they were trying to do there.

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Getting index of the smallest number in a list 1 Answer

NullReferenceException problem 2 Answers

Missing Reference FPS help 1 Answer

Convert to C#,I don't know how to convert this 1 Answer

Null in GetValidMethodInfo 0 Answers


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