0
Fixed

Errors on Android build

Nige 7 years ago updated by Aaron Brown 7 years ago 11

Hi,


When building for Android I am seeing this error:

Assets/LushLOD Trees/Scripts/_LushLODTreesManager.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?


If I then wrap the "Using UnityEditor" in an if_UNITY_EDITOR conditional and try again I get these errors:


Assets/LushLOD Trees/Scripts/_LushLODTreesManager.cs(1460,17): error CS0103: The name `EditorUtility' does not exist in the current context

Assets/LushLOD Trees/Scripts/_LushLODTreeWarning.cs(40,44): error CS0103: The name `AssetDatabase' does not exist in the current context

Assets/LushLOD Trees/Scripts/_LushLODTreeWarning.cs(49,58): error CS0103: The name `AssetDatabase' does not exist in the current context


Yay, just what you need when trying to get the beta out the door 


Do you recommend your system for Android btw?

Under review

What version of Unity are you using?

I loaded up _LushLODTreesManager.cs and it already has #IF UNITY_EDITOR wrapped around every occurrence of UnityEditor in the file as far as I can tell. Also the top of the file looks like this:


using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif 
using System.Collections;
using System.Collections.Generic;


So the statement "using UnityEditor;" is already wrapped in the if as well. So I'm confused how you're not seeing the #if wraps?


Hi sorry for the confusion - I was part way through trying to debug this myself ...


I reimported LushLOD and am now getting this error:


Assets/LushLOD Trees/Scripts/_LushLODPostProcessor.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?


This was the actual error flagged by our developer 

Darn, you're right, there is a using UnityEditor in that file that isn't wrapped. That post processor script doesn't even use UnityEditor anywhere as far as I can tell... you can simply comment out that "using UnityEditor;" line and the error should go away, since that line isn't even used or needed.


Let me know if that fixes it, or if there are any other unwrapped UnityEditor code that you find. 


If this fixes it, I'll be sure to remove that line from the next update so you won't see this happen again.

Hi,


Ok so we still get these errors when building:


Assets/LushLOD Trees/Scripts/_LushLODTreesManager.cs(1460,17): error CS0103: The name `EditorUtility’ does not exist in the current context

[3:49] 
Assets/LushLOD Trees/Scripts/_LushLODTreeWarning.cs(40,44): error CS0103: The name `AssetDatabase’ does not exist in the current context

[3:49] 
Assets/LushLOD Trees/Scripts/_LushLODTreeWarning.cs(49,58): error CS0103: The name `AssetDatabase’ does not exist in the current context


Sorry about that, 


For the tree warning script, you can wrap the entire CheckTree() function in the #IF. Don't wrap the whole file in an if, because the class name still needs to exist. But the CheckTree() can be fully wrapped in the IF, and that should fix that file.


And for that line in the manager file, yep it looks like I missed that line to. You can replace that line with this code for now:


#if UNITY_EDITOR
                string ErrorMsg923 = "You have a tree named \"" + TreeUsingFastShader.Original_TreeName + "\" (instance \"" + TreeUsingFastShader.name + "\") that is using one of the Fast shaders. In this beta version, the Ultra quality level currently does not support the TreeCreatorLeavesFAST or TreeCreatorBarkFAST shaders. Only the non-fast shaders are supported. Expect this to be fixed soon. For now, if you wish to use Ultra quality, you must ensure that no parts of any of your Unity trees are using any of Unity's \"Fast\" Tree shaders. This needs to be done prior to converting your trees to LushLOD trees, and cannot be done after conversion. You can easily upgrade your scene to use the new trees after you re-convert them (All LushLOD trees in your scene have an upgrade button)."
                EditorUtility.DisplayDialog(ErrorMsg923, "Okay");
#else
                UnityEngine.Debug.LogError(ErrorMsg923);
#endif


And I will put these fixes into the next update as well. Let me know if there are any more errors that appear.

Ok so now I get these 2 errors- 


Assets/LushLOD Trees/Scripts/_LushLODTreesManager.cs(1462,61): error CS1001: Unexpected symbol `You have a tree named "', expecting identifier


Assets/LushLOD Trees/Scripts/_LushLODTreesManager.cs(1463,59): error CS1001: Unexpected symbol `Okay', expecting identifier

Ok so got rid of the errors by replacing the commer after "Not Supported Yet" with an addition sign, adding a semi colon to the end of that line and giving the EditorUtility.DisplayDialog method a title (first parameter before the message.


Going to try and build now so fingers crossed ...

Ok so once I'd moved the declaration of the string ErrorMsg923 up to the top of CheckTree() all seems well. 


Thanks for the support

Fixed

Sorry about that comma lol, yeah right after I posted that message I saw the comma and I quickly edited what I said. But you must have grabbed the text before I got my edit made. :) Anyway, I had to take my grandma to a doctor appointment but I'm glad you got it working. :)