#Unity dumps errors without clear reason

1 messages · Page 1 of 1 (latest)

eager spindle
#

I have several events where trying to build the project infuriates me a ton. Back then, Unity would build my projects just fine without any questions, let alone cancel the building process (if any).

Now it's being overtly sensitive about where do I call things from, I need to add an explicit qualifier despite already calling usings, and it complains about using editor codes, while the code is within UNITY_EDITOR ifdef??? This confused me a ton, which is why I'd say it's complaining without clear reason

Did I mess up any configurations in the preferences or project settings? or did I accidentally delete any directory I'm not supposed to? (This is running on linux)

jovial mountain
eager spindle
# jovial mountain https://unity.huh.how/building/editor-assemblies

One of them where it complained (RightClickButton.cs) followed the rule already:

using UnityEditor;
using UnityEditor.UI;

#if UNITY_EDITOR
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
#endif

namespace JANOARG.Chartmaker.UI
{

    public class RightClickButton : Button
    {
        public UnityEvent onRightClick;

        public override void OnPointerUp(PointerEventData eventData)
        {
            base.OnPointerUp(eventData);
            if (eventData.button == PointerEventData.InputButton.Right) 
                onRightClick.Invoke();
        }
    }

#if UNITY_EDITOR
    [CustomEditor(typeof(RightClickButton), true)]
    [CanEditMultipleObjects]
    public class RightClickButtonInspector : ButtonEditor {
        public override void OnInspectorGUI(){
            base.OnInspectorGUI();
            this.serializedObject.Update();
     
            EditorGUILayout.PropertyField(serializedObject.FindProperty("onRightClick"));
        
            serializedObject.ApplyModifiedProperties();
        }
    }
#endif
}
jovial mountain
#

now look at your using directives, you'll notice the preprocessor directive is doing the opposite of what you want it to be doing

eager spindle
#

what gives?

jovial mountain
#

since the symbol is defined while working in the editor there are no issues here when using this code in the editor. it's only when you attempt to build that it breaks because you are trying to use an Editor-Only namespace outside of that preprocessor directive

eager spindle
jovial mountain
#

presumably this code either did not exist or was different (meaning it was set up correctly)

eager spindle
#

another instance is where I have to type UnityEngine.Debug.Log(); while I already have using UnityEngine;

#

(no ifdefs)

jovial mountain
eager spindle
jovial mountain
#

show the relevant code then

#

and provide the actual error message instead of making me guess

eager spindle