- Home /
ArgumentException: method return type is incompatible
So I am using the Unity 4.6 UI Buttons when this error came up:
ArgumentException: method return type is incompatible System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Delegate.cs:190) System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Delegate.cs:276) UnityEngine.Events.InvokableCall..ctor (System.Object target, System.Reflection.MethodInfo theFunction) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:98) UnityEngine.Events.PersistentCall.GetRuntimeCall (UnityEngine.Events.UnityEventBase theEvent) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:355) UnityEngine.Events.PersistentCallGroup.Initialize (UnityEngine.Events.InvokableCallList invokableList, UnityEngine.Events.UnityEventBase unityEventBase) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:517) UnityEngine.Events.UnityEventBase.RebuildPersistentCallsIfNeeded () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:673) UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:709) UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53) UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/guisystem/UI/Core/Button.cs:35) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/guisystem/UI/Core/Button.cs:44) UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/guisystem/EventSystem/ExecuteEvents.cs:52) UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/guisystem/EventSystem/ExecuteEvents.cs:269) UnityEngine.EventSystems.EventSystem:Update()
Here's my Script:
#pragma strict
var login : GameObject;
var create : GameObject;
var f : float;
var i : int = 0;
private var swipe : boolean = true;
function Update ()
{
if (i > 0)
{
swipe = true;
var b : GameObject = gameObject.FindGameObjectWithTag("B2");
b.GetComponent(UI.Button).interactable = true;
}
if (i == 0)
{
var b2 : GameObject = gameObject.FindGameObjectWithTag("B2");
b2.GetComponent(UI.Button).interactable = false;
}
if (i <= -1)
{
swipe = false;
}
}
function LoginToForgot ()
{
iTween.MoveTo(login,Vector3(-15,0,0),1);
iTween.MoveTo(create,Vector3(0,0,0),1);
}
function ForgotToLogin ()
{
iTween.MoveTo(login,Vector3(0,0,0),1);
iTween.MoveTo(create,Vector3(15,0,0),1);
}
function SkateparksRight ()
{
if (swipe == true)
{
i++;
swipe = false;
var alga : GameObject = gameObject.FindGameObjectWithTag("AlgaTest");
var aura : GameObject = gameObject.FindGameObjectWithTag("AuraTest");
var cbp : GameObject = gameObject.FindGameObjectWithTag("CBPTest");
iTween.MoveTo(alga,Vector3(alga.transform.position.x - f,alga.transform.position.y,alga.transform.position.z),1);
iTween.MoveTo(aura,Vector3(aura.transform.position.x - f,aura.transform.position.y,aura.transform.position.z),1);
iTween.MoveTo(cbp,Vector3(cbp.transform.position.x - f,cbp.transform.position.y,cbp.transform.position.z),1);
yield WaitForSeconds (1);
swipe = true;
}
}
function SkateparksLeft ()
{
if (swipe == true)
{
i--;
swipe = false;
var alga : GameObject = gameObject.FindGameObjectWithTag("AlgaTest");
var aura : GameObject = gameObject.FindGameObjectWithTag("AuraTest");
var cbp : GameObject = gameObject.FindGameObjectWithTag("CBPTest");
iTween.MoveTo(alga,Vector3(alga.transform.position.x + f,alga.transform.position.y,alga.transform.position.z),1);
iTween.MoveTo(aura,Vector3(aura.transform.position.x + f,aura.transform.position.y,aura.transform.position.z),1);
iTween.MoveTo(cbp,Vector3(cbp.transform.position.x + f,cbp.transform.position.y,cbp.transform.position.z),1);
yield WaitForSeconds (1);
swipe = true;
}
}
function AfterSubmission ()
{
var logIn : GameObject = gameObject.FindGameObjectWithTag("LogIn");
var createAccount : GameObject = gameObject.FindGameObjectWithTag("CreateAccount");
var skateparks : GameObject = gameObject.FindGameObjectWithTag("Skateparks");
iTween.MoveTo(logIn,Vector3(0,20,0),1);
iTween.MoveTo(createAccount,Vector3(15,20,0),1);
iTween.MoveTo(skateparks,Vector3(0,0.4,-0.01),1);
}
function SignOut ()
{
var logIn : GameObject = gameObject.FindGameObjectWithTag("LogIn");
var createAccount : GameObject = gameObject.FindGameObjectWithTag("CreateAccount");
var skateparks : GameObject = gameObject.FindGameObjectWithTag("Skateparks");
iTween.MoveTo(logIn,Vector3(0,0,0),1);
iTween.MoveTo(createAccount,Vector3(15,0,0),1);
iTween.MoveTo(skateparks,Vector3(0,-20,-0.01),1);
}
Thanks!
It happens to me too, when adding yield WaitforSeconds() to my script. If i remove yield it works fine, but I cant see animations :)
Answer by Bwhang · Nov 04, 2016 at 05:00 PM
This happened to me too. I got rid of the message by making sure my onscreen input was set to an int rather than a float. I had a variable (float) that was fed by the keyboard arrow keys or joystick input. I tried to have my onscreen buttons input a float as well for left and right: -.99 and .99. This didn't work.
Had to set that variable to an int with -1 and 1 to make it work. It's OK to not have the float for the keyboard and joystick since this ended up being the code just for an android version.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174524im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
button question 1 Answer
destroy child object 2 Answers
GUI cale and position according to the actual screen resolution. 1 Answer
Raycast Destroys player. 1 Answer