• 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
Question by godsinmyroom · Sep 13, 2015 at 09:36 AM · script errorconditional

Empty error and error in class that was running

Ok, I'm asking because I'm very tired of searching for solutions, make editions and get more and more errors.

My game was working. Everything was fine (yes, I have backups and can restore it).I made a beta version and some people tested it. Worked like a charm. Them I started to make some changes to publish in into some game websites. To make the things easier and don't have to have specific copies for each website, I started to use conditional compilers.

Note: the API for Gamejolt was imported before it into the project, and the standalone was built, tested, no errors.

I wanted to use [Conditional("CONDITION")] to especify if the method can be executed. In some cases I will use #if too, but conditional is more "elegant" to me.

So, I put the smcs.rsp in the /Assets/ with the following:

 -define: GAMEJOLT

So, to use [Conditional] I need to specify System.Diagnostics

Them the Debug isn't exist anymore (unknow error). So I need to use using Debug = UnityEngine.Debug; to correct the thing. The start of the code is now:

        using UnityEngine;
         using System.Collections;
         using System.Diagnostics;
         using Debug = UnityEngine.Debug;
         
         
         public class LogoScreen : MonoBehaviour {
         
             bool autoPlayAnim = false;
             private Animator animator;
 
     .... [the middle of the thing, not changed from the functional version]
 
     [Conditional("GAMEJOLT")]
     void LoginToGameJolt(){
 
         Debug.Log("Here the login for gamejolt");
 
     }
 

Debug exist again. But I get the empty error in the console. The red symbol of "you are doomed" and nothing more. A search (long one) on Google and "it caused by type mismatch between the filename of the script and the class name".

In my case it wasn't. The two class that now are saying "No MonoBehavior scripts in the file, or their name do not match the file name." I don't have changed those classes, they was working before even with this alert.

The code of the class:

   /* Script: Utilities.cs
      * 
      * Library with utility functions
      * 
      */
     using UnityEngine;
     using System.Collections;
     
     public class Utilities {
     
         //Get a color in the three colors gradient 
         //that match the percent
         public Color GetColorHealth(float percent){
     
             Gradient g;
             GradientColorKey[] gck;
             GradientAlphaKey[] gak;
     
 .... [the rest of the thing]
 

My game was working before I tried only to use Conditional. And now any new script that I try to create in Unity, using Create->C# Script gives me the same error, even with MonoBehavior and name is ok. But only in this project. Other projects that doesn't have the Conditional is working.

Then I ripped off all the code that use the conditional (only one class), deleted the rmcs.rsp and no way to get the things working back. I even tried to Reimport All.

The backup is working, the version with the changes, no way to work again.

There is something that I'm missing?

(I worked with a lot of languages and frameworks in my life, even becoming a collaborator in an Access & VB magazine long time ago after resolving a crazy weird stupid problem. Now, no way, Unity is winning the fight for now :P )

Comment

People who like this

0 Show 0
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

0 Replies

  • Sort: 

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

#if UNITY_WEBPLAYER been removed? 2 Answers

Scripts named 'Grenade.js' exist in multiple locations 1 Answer

Objects acting under each other's gravity. Test 1 Answer

2D C# Jump Script Addforce 2 Answers

Can't add script 2 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