I am having problem with building a game. it keep saying 'Error building Player because scripts have compile errors in the editor'
I followed tips from this and still got nothing on working.
a friend suggested me to add
public static class EditorUtil
{
#if UNITY_EDITOR
//Editr code here
#endif
}
and it still continues with same error.
this is the full code:
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
public static class EditorUtil
{
#if UNITY_EDITOR
//Editr code here
static string m_EditorResourcesPath = string.Empty;
private static string path = string.Empty;
internal static string editorResourcesPath
{
get
{
if (string.IsNullOrEmpty(m_EditorResourcesPath))
{
string path;
if (SearchForEditorResourcesPath(out path))
m_EditorResourcesPath = path;
else
Debug.LogError("Unable to locate editor resources. Make sure the PostProcessing package has been installed correctly.");
}
return m_EditorResourcesPath;
}
}
static bool SearchForEditorResourcesPath(out string path)
{
path = string.Empty;
string searchStr = EditorUtil.path;
string str = null;
foreach (var assetPath in AssetDatabase.GetAllAssetPaths())
{
if (assetPath.Contains(searchStr))
{
str = assetPath;
break;
}
}
if (str == null)
return false;
path = str.Substring(0, str.LastIndexOf(searchStr) + searchStr.Length);
return true;
}
internal static T Load<T>(string path, string name) where T : Object
{
EditorUtil.path = path;
return AssetDatabase.LoadAssetAtPath<T>(editorResourcesPath + name);
}
private static List<string> layers;
private static string[] layerNames;
public static LayerMask LayerMaskField(string label, LayerMask selected)
{
if (layers == null)
{
layers = new List<string>();
layerNames = new string[4];
}
else
{
layers.Clear ();
}
int emptyLayers = 0;
for (int i = 0; i < 32; i++)
{
string layerName = LayerMask.LayerToName (i);
if (layerName != "")
{
layers.Add (layerName);
}
else
{
emptyLayers++;
}
}
if (layerNames.Length != layers.Count)
{
layerNames = new string[layers.Count];
}
for (int i=0; i < layerNames.Length; i++)
layerNames[i] = layers[i];
selected.value = EditorGUILayout.MaskField (label, selected.value, layerNames);
return selected;
}
public static Rect GetCurrentRect (float fieldSize = 18)
{
return GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(fieldSize));
}
public static GameObject GetSelectedGameObject ()
{
return Selection.activeGameObject;
}
public static AnimationClip GetAnimationClipFromAnimator(Animator animator, string name)
{
if (animator == null)
return null;
foreach (AnimationClip animClip in animator.runtimeAnimatorController.animationClips)
{
if (animClip.name == name)
return animClip;
}
return null;
}
#endif
}
whats a solution for this? I've searched many posts in here and other forums and yet I keep getting the same error.
Edit: second pic