- Home /
Error CS0103?
Hi,
I'm getting a CS0103 error, Assets/Sample Assets/2D/Scripts/Platformer2DUserControl.cs(19,21): error CS0103: The name CrossPlatformInput' does not exist in the current context and Assets/Sample Assets/2D/Scripts/Platformer2DUserControl.cs(31,27): error CS0103: The name
CrossPlatformInput' does not exist in the current context
Here is my code:
the error is that you haven't provided a reference to CrossPlatformInput
. where is it defined?
How do I use code tags? Is there a way to search the entire code to see where else CrossPlatformInput is defined?
using UnityEngine;
[RequireComponent(typeof(PlatformerCharacter2D))] public class Platformer2DUserControl : $$anonymous$$onoBehaviour { private PlatformerCharacter2D character; private bool jump;
void Awake()
{
character = GetComponent<PlatformerCharacter2D>();
}
void Update ()
{
// Read the jump input in Update so button presses aren't missed.
#if CROSS_PLATFOR$$anonymous$$_INPUT
if (CrossPlatformInput.GetButtonDown("Jump")) jump = true;
#else
if (Input.GetButtonDown("Jump")) jump = true;
#endif
}
void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.Get$$anonymous$$ey($$anonymous$$eyCode.LeftControl);
#if CROSS_PLATFOR$$anonymous$$_INPUT
float h = CrossPlatformInput.GetAxis("Horizontal");
#else
float h = Input.GetAxis("Horizontal");
#endif
// Pass all parameters to the character control script.
character.$$anonymous$$ove( h, crouch , jump );
// Reset the jump input once it has been used.
jump = false;
}
}
Question, where does CrossPlatformInput refer to? I can't find it in the UnityReference.
You also define "float h" two times which I don't understand.
h
is defined in a conditional, so only really once. it ain't pretty, but it'll work ;)
appreciate the help. i added the CrossPlatformInput from the sample assets and got the project functioning again!
Answer by JohnnySunshine · Jul 28, 2014 at 01:33 PM
If you have this error, and CROSS_PLATFORM_INPUT
is defined, then you probably imported the Sample Assets and somehow deleted CrossPlatformInput.cs
. You should reimport it from the package (along with the whole Cross Platform Input folder), and it will work again.
Alternatively, if you were deliberately trying to get rid of it, go to Edit > Project Settings > Player Settings, look for the Other Settings tab, and remove CROSS_PLATFORM_INPUT
from Scripting Define Symbols.
thanks for the help guys. i added the CrossPlatformInput from the sample assets and got the project functioning again!
Your answer
Follow this Question
Related Questions
weird false cs0103 error in monodevelop 3 Answers
Error Code CS0103 1 Answer
Error from the Time Of day asset?? 0 Answers
Odd compiler and "Error CS0103" 1 Answer
Error CS0103: The name `ctn' does not exist in the current context ?? 1 Answer