简体   繁体   中英

Unity gives strange errors when i try to build my project

Unity gives me these strange errors for some reason when i try to build my project. I do not know why it gives me these errors, when they should've been given earlier. I've tried restarting unity, deleting the "plugins" folder, deleting the .sln files and putting the build folder on a different folder. How can i fix these strange errors??

here's the code unity keeps giving me errors from, if that helps anything: https://paste.myst.rs/lwj5nsm1

And here's the errors unity gave me:

Assets\\LevelGenerator\\Scripts\\Editor\\LevelEditor.cs(9,30): error CS0115: 'GeneratorEditor.OnInspectorGUI()': no suitable method found to override

Assets\\LevelGenerator\\Scripts\\Editor\\LevelEditor.cs(7,48): error CS0234: The type or namespace name 'Editor' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)

Assets\\LevelGenerator\\Scripts\\Editor\\LevelEditor.cs(6,6): error CS0246: The type or namespace name 'CustomEditorAttribute' could not be found (are you missing a using directive or an assembly reference?)

Assets\\LevelGenerator\\Scripts\\Editor\\LevelEditor.cs(6,6): error CS0246: The type or namespace name 'CustomEditor' could not be found (are you missing a using directive or an assembly reference?)

UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in :0 at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in :0 UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Your code is used for the editor, and therefore should not be included in the build result.What I do to solve this, I create a "DONOTCOMPILETHIS" build directive that I add to the player Settings. PlayerSetting DLG

and finaly in your code add :

using UnityEngine;

#if !DONOTCOMPILETHIS

using UnityEditor;

using UnityEditor.IMGUI.Controls;


[CustomEditor(typeof(CGameTower)), CanEditMultipleObjects]

public class CBoundRectEditor : Editor

{

    private BoxBoundsHandle m_BoundsHandle = new BoxBoundsHandle();


    ...

}

#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM