Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
1
Question by Shadow_X · Feb 23, 2016 at 09:55 PM · cs0246

How can i fix the error code CS0246?

Hello everyone:)

I'm really annoyed with this problem...

Here is the error:

Assets/TypeOut/Scripts/TypeOutEditor.cs(2,7): error CS0246: The type or namespace name UnityEditor' could not be found. Are you missing a using directive or an assembly reference? Assets/TypeOut/Scripts/TypeOutEditor.cs(3,7): error CS0246: The type or namespace name UnityEditorInternal' could not be found. Are you missing a using directive or an assembly reference?

Script:

using UnityEngine;
using UnityEditor;
using UnityEditorInternal; using System;

[CustomEditor(typeof(TypeOutScript))] public class TypeOutEditor : Editor {

 private string ontxt = "Turn On";

 private SerializedObject TOS;
 private SerializedProperty finalText;
 private SerializedProperty On;
 private SerializedProperty Reset;
 private SerializedProperty TotalTypeTime;
 private SerializedProperty TypeRate;
 private SerializedProperty RandomCharacterChangeRate;

 enum TimeModes {TotalTime = 0, TypeRate =1};
 TimeModes TM = TimeModes.TotalTime;
 private float Time = 0.5f;
 private float RCCR = 0.1f;

 public void OnEnable()
 {
     if (target == null)
     {
         return;
     }

     TOS = new SerializedObject(target);
     finalText = TOS.FindProperty("FinalText");
     On = TOS.FindProperty("On");
     Reset = TOS.FindProperty("reset");
     TotalTypeTime = TOS.FindProperty("TotalTypeTime");
     TypeRate = TOS.FindProperty("TypeRate");
     RandomCharacterChangeRate = TOS.FindProperty("RandomCharacterChangeRate");
 }


 public override void OnInspectorGUI() 
 {
     TOS.Update();

     finalText.stringValue = ParseNewline(finalText.stringValue.Trim());

// EditorGUILayout.PropertyField(On); // EditorGUILayout.PropertyField(Reset);

     EditorGUILayout.BeginHorizontal ();

     if(GUILayout.Button(ontxt))
     {
         if (On.boolValue == true)
         {
             On.boolValue = false;
             ontxt = "Turn On";
         }
         else
         {
             On.boolValue = true;
             ontxt = "Turn Off";
         }
     }

     if (On.boolValue == true)
     {
         ontxt = "Turn Off";
     }
     else
     {
         ontxt = "Turn On";
     }

     if(GUILayout.Button("Reset"))
     {
         Reset.boolValue = true;
     }

     EditorGUILayout.EndHorizontal ();

     EditorGUILayout.Space();

// GUI.Label(new Rect(0, 40, 100, 40), GUI.tooltip); EditorGUILayout.LabelField("FinalText:"); EditorGUILayout.LabelField("note: '\\n' for new line"); EditorGUILayout.PropertyField(finalText, GUIContent.none,GUILayout.Height(50));

     EditorGUILayout.Space();

     EditorGUILayout.BeginHorizontal ();

     TM = (TimeModes) EditorGUILayout.EnumPopup(TM);

     if (TM == TimeModes.TotalTime)
     {
         Time = EditorGUILayout.Slider(Time,0f, 10f);
         TotalTypeTime.floatValue = Time;
     }
     else
     {
         Time = EditorGUILayout.Slider(Time,0f, 1f);
         TotalTypeTime.floatValue = -1f;
         TypeRate.floatValue = Time;
     }
     EditorGUILayout.EndHorizontal ();

     EditorGUILayout.Space();

     EditorGUILayout.LabelField("Random Character Change Rate");

     RCCR = EditorGUILayout.Slider(RCCR,0f, 1f);
     RandomCharacterChangeRate.floatValue = RCCR;

     TOS.ApplyModifiedProperties();

 }

 private string ParseNewline(string s)
 {
     s = s.Replace("\\n","|");
     
     string[] SS = s.Split('|');
     
     string ReturnString = "";
     
     foreach (string rp in SS)
     {
         ReturnString = ReturnString + rp + "\n";
     }
     
     return ReturnString;
 }

}

Pls help and describe detailed:)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by nonathaj · Feb 24, 2016 at 12:59 AM

It makes sense that you would receive this error when trying to create builds. Any script that uses UnityEditor should either use preprocessor directives for UNITY_EDITOR or be places in an Editor Folder.

If you are receiving this error when trying to run in the editor it is possible that your solution has been corrupted or is not being properly referenced. I would recommend deleting all the generated csproj files and solution (sln) file from your project folder. The next time you open Unity it should regenerate those files with the appropriate references.

Comment
Add comment · Show 1 · 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
avatar image Shadow_X · Feb 24, 2016 at 11:24 AM 0
Share

Nothing worked what i tried.

But i dont know how to use preprocessor directives for UNITY_EDITOR or be places in an Editor Folder? Can you explain it more detailed?

thx for the help:)

avatar image
2

Answer by NoseKills · Feb 24, 2016 at 03:32 PM

By the looks of it ...

 [CustomEditor(typeof(TypeOutScript))]

...it is an editor script so it should be placed in a folder called 'Editor' anywhere in your project as instructed in many answers already

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

47 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

Related Questions

error CS0246: The type or namespace name `PlayerMovement' could not be found. Are you missing an assembly reference? 1 Answer

Tell me how to fix the script error CS0246 0 Answers

Compiler errors (CS0246 & CS0234) 0 Answers

Help getting Tanks AR Demo (Unite 2017) to work,Unity Tanks AR Networking Demo (Unite 2017) is not working 0 Answers

Help getting Unite 2017 demo code to run, need to fix errors 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