- Home /
Project contains compiler errors
Hi, since 2 days ago whenever I open one of my Unity projects I'm getting an error while loading editor saying my project has got compiler errors and suggesting me to enter safe mode; afterwards, once in the editor I get an error message in the console saying
Init must be called first.
I want to know the reason because this is happening, hence I will comment the possible critical changes I had done the previous day to the first time getting this error:
Updated Unity Hub to it's newer beta version 3.0.0
Created an editor script for adding a button to Animator to automatically generate a class with animation parameters names as constants (class down here)
using UnityEngine; using UnityEditor; using System.IO; using System.Linq;
[CustomEditor(typeof(Animator))] public class AnimatorExtensionsEditor : Editor { private Animator animator;
public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUILayout.Space(); GUILayout.Label("Animation Extras:"); if (GUILayout.Button($"Generate {Selection.activeGameObject.name} animator c# class")) { animator = Selection.activeGameObject.GetComponent<Animator>(); GenerateAnimatorClass(Selection.activeGameObject.name + "AnimatorParameters", animator.parameters.Select(p => p.name.Replace(' ', '_').ToUpper()).ToArray(), animator.parameters.Select(p => p.name).ToArray()); GUIUtility.ExitGUI(); } } private void GenerateAnimatorClass(string className, string[] constantsNames, string[] constantsValues) { string path = EditorUtility.SaveFilePanel($"Generate animator class for {Selection.activeGameObject.name}", string.Empty, $"{className}.cs", ".cs"); if (path == string.Empty) return; string classDeclaration = $"public static class {className}"; string[] fields = new string[constantsNames.Length]; string finalClass = classDeclaration + '\n' + '{' + '\n'; for (int i = 0; i < fields.Length; i++) { fields[i] = ConstDeclaration(constantsNames[i], constantsValues[i]); finalClass += '\t' + fields[i] + '\n'; } finalClass += '}'; File.WriteAllText(path, finalClass); AssetDatabase.Refresh(); const char apostrophe = '"'; static string ConstDeclaration(string constName, string constValue) => $"public const string {constName} = {apostrophe}{constValue}{apostrophe};"; } }
I'm seeing the same error and this only happened since I updated Unity Hub to the 3.0.0-beta. I would guess this is the cause based on you seeing the same thing. I did not have any other changes to my project besides that.
The new unity hub update did a lot of damage here too...basically it uninstalled my editor...after reinstalling tho..there is no real problem
Your answer
Follow this Question
Related Questions
Select between different Custom Editors for same Monobehaviour 0 Answers
How to create a textfield in custom window editor using a button? 1 Answer
How to design a terrain paint tool in script by TerrainPaintTool? 0 Answers
How to make a custom inspector to preview tile? 0 Answers
How can I get time of compiling to use used in a progress bar in a custom editor? 0 Answers