Hi everyone!
I have a problem when I try to build a project that uses a custom
action.
I created the script following the "Writing a custom action" tutorial and
everything's works fine when I try the game in Unity, but when I compile the
project I get the following errors:
- error CS0115: `AC.ActionMyAnimation.ShowGUI()' is marked as an override
but no suitable method found to override;
- error CS0246: The type or namespace name `UnityEditor' could not be
found. Are you missing a using directive or an assembly reference?
It looks like it can't find the reference to UnityEditor, but I don't know
why...
The build settings are:
- target platform: windows;
- architecture: x86 (tried also x86_64 with the same result)
- development build: unchecked
Here's the code of the script:
using UnityEngine;
using System.Collections;
using UnityEditor;
namespace AC
{
[System.Serializable]
public class ActionMyAnimation :
Action
{
// Declare variables here
public Animator animator = null;
public ActionMyAnimation()
{
this.isDisplayed = true;
category = ActionCategory.Object;
title = "My Animation";
animator = new Animator();
}
public override void ShowGUI()
{
animator = (Animator)EditorGUILayout.ObjectField("Animator :",
animator, animator.GetType(), true, null);
AfterRunningOption();
}
override public float Run ()
{
//do stuff
}
}
}
Anyone knows why I get this problem?
Thanks!
Bye
Comments
This is an oversight with the tutorial, and I apologise - will update it with corrections. In the meantime, you can see how these directives should be placed in your script by examining the "ActionTemplate.cs" example script.