Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 RHoogland · Oct 11, 2015 at 10:33 AM · c#monodevelop

'new' keyword compilation issue on transferring game to new PC

I am totally confused, as I had to relocate my game to another faster laptop. Both laptops run with Windows8.1 and Unity 5.2.0f3 personal.
On the 2nd laptop suddenly the error comes up: You are trying to create a Mono Behavior using the 'new' keyword in several of my C# files. Here follows part of the code of one of my files where this error occurs. Basically I am just creating an array of Vector3. The previous laptop didn't have this problem at all. To be sure I moved my game to a third laptop, with the same problem. Can anybody help me out ? Thanks a lot:

 public class Fifo : MonoBehaviour {    
            
              private int N; //used fifo length    
              private static float T;    
              public Vector3[] value = new Vector3[200];//max available fifo length    
              public float[] time = new float[200];//max available fifo length    
              private bool full = false;    
              private int fillLevel = 0;
  
                  
              //constructor    
              public Fifo(int fifoLength)    
              {
                           this.N = fifoLength;                    
              }//end constructor()
             
             
  
              public void shift(Vector3 newvalue, float newtime)    
              {                                    
                                     int i = 0;    
                                     while (i < this.N - 1) {    
                                                 this.value [i].x = this.value [i + 1].x;    
                                                 this.value [i].y = this.value [i + 1].y;    
                                                 this.value [i].z = this.value [i + 1].z;    
                                                 this.time [i] = this.time [i + 1];    
                                                 i = i + 1;    
                                     }//end while    
              
                                     this.value [this.N - 1].x = newvalue.x;    
                                     this.value [this.N - 1].y = newvalue.y;    
                                     this.value [this.N - 1].z = newvalue.z;    
                                     this.time [this.N - 1] = newtime;    
                                     if (!this.full)    
                                                 this.fillLevel = this.fillLevel + 1;    
                                     if (this.fillLevel >= this.N)    
                                                 this.full = true;                  
              
              }//end shift()
  
          
  
      
  
  
 
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 getyour411 · Oct 11, 2015 at 03:46 PM 0
Share

That's generally a warning (yellow !) not an error; you might have turned off warnings in your Unity console options on the other computer.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Suddoha · Oct 11, 2015 at 12:30 PM

You are not supposed to create a class derived from MonoBehaviour by your own constructor which you've defined there and which is probably called somewhere in another script, as Unity does the actual object creation internally when a component is added to a gameobject.

For initialization, Awake and Start should be used.

So far there doesn't seem to be any code in that class that needs access to a MonoBehaviours members, so you could remove the inheritance (perhaps you simply forgot to remove it).

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Cant get Monodevolop to work 0 Answers

Glitch in Monodevelop for loops!!! 1 Answer

MonoDevelop won't open in Unity 5? 5 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