UnityThirdPersonTutorial icon indicating copy to clipboard operation
UnityThirdPersonTutorial copied to clipboard

Answered: Error with scripts when building Player

Open theviolinmasta opened this issue 11 years ago • 4 comments

How do I fix this?

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

and

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

Error building Player because scripts had compiler errors

theviolinmasta avatar Jan 02 '15 15:01 theviolinmasta

The UnityEditor namespace isn't included in builds, which is causing the problem. You can move "ThirdPersonCameraEditor.cs" to a new folder called "Editor" (Unity arbitrarily excludes this folder from builds), and wrap the editor debug code in ThirdPersonCamera.cs in "#if UNITY_EDITOR" and "#endif" preprocessor statements to exclude them from builds. Specifically, at the beginning of ThirdPersonCamera.cs:

using UnityEngine;
using System.Collections;

#if UNITY_EDITOR
using UnityEditor;
#endif

and in the "Unity event functions" region:

#if UNITY_EDITOR
/// <summary>
/// Debugging information should be put here.
/// </summary>
void OnDrawGizmos ()
{   
    if (EditorApplication.isPlaying && !EditorApplication.isPaused)
    {           
        DebugDraw.DrawDebugFrustum(viewFrustum);
    }
}
#endif

Hope that helps you out!

zr3 avatar Jan 06 '15 19:01 zr3

Thank you! Working great now!

theviolinmasta avatar Jan 06 '15 21:01 theviolinmasta

I've tryed all this and it does not work for me... :( pls help

Species-8472 avatar Apr 20 '17 17:04 Species-8472

changed the character mat and will be adding more ui and weapons to character that you will be able to switch out. COMMING SOON!!!

OkashiKami avatar Apr 22 '17 14:04 OkashiKami