Okay so I'm learning to use the new InputActions and I've created a C# scripts using
https://prnt.sc/oyaj5l
And this is what I got:
// GENERATED AUTOMATICALLY FROM 'Assets/PlayerControls.inputactions'
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
public class PlayerControls : IInputActionCollection
{
private InputActionAsset asset;
public PlayerControls()
{
///
}
}
But when I try to create an PlayerControls object, I get an error saying
The type or namespace name 'PlayerControls' could not be found (are you missing a using directive or an assembly reference?)
This is the class where I try to reference it:
using System;
using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;
using UnityEngine.InputSystem;
namespace UnityStandardAssets.Characters.FirstPerson
{
public class FirstPersonController : MonoBehaviour
{
private PlayerControls controls; // ERROR HERE
}
}
Wrap the PlayerControls class in a namespace, then add a using statement in your class that points to the namespace where your PlayerControls class lives.
I solved it!
It looks like Unity has a compile order. I referenced this: http://answers.unity.com/answers/1274460/view.html and managed to solve it after seeing that "Standard Assets" has priority over other assets
Related
I am using Unity and I'm getting a 'The type or namespace name 'Mine' could not be found (are you missing a using directive or an assembly reference?)' error. I know this means that you are usually missing a using statement, but this is not the case this time. Take a look at the beginning of the 2 script at question. The error is flagged at "public WarmList list;"
using UnityEngine;
using Mine;
namespace PolymindGames.BuildingSystem
{
[RequireComponent(typeof(CookingStation))]
//public class CampfireEffects : MonoBehaviour
public sealed class CampfireEffects : MonoBehaviour
{
public WarmList list;
...
}
}
And script 2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Mine
{
public class WarmList : MonoBehaviour
{...
}
}
Why can't script one see class 2? I don't think I am doing anything wrong? I have tried so many solutions but nothing works, I keep getting that complier error.
These are my 3 errors that I have:
Assets/Scripts/Controllers/PlayerController.cs(13,27): error CS0115: 'PlayerController.RetrieveMoveInput()': no suitable method found to override
Assets/Scripts/Controllers/PlayerController.cs(8,26): error CS0115: 'PlayerController.RetrieveJumpInput()': no suitable method found to override
Assets/Scripts/Controllers/PlayerController.cs(6,33): error CS0246: The type or namespace name 'InputController' could not be found (are you missing a using directive or an assembly reference?)
This was the video I was watching: https://www.youtube.com/watch?v=lcw6nuc2uaU&t=140s
These are my 2 scripts:
InputController:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class Input : ScriptableObject
{
public abstract float RetrieveMoveInput();
public abstract bool RetrieveJumpInput();
}
PlayerController:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "PlayerController", menuName = "InputController/PlayerController")]
public class PlayerController : InputController
{
public override bool RetrieveJumpInput()
{
return Input.GetButtonDown("Jump");
}
public override float RetrieveMoveInput()
{
return Input.GetAxisRaw("Horizontal");
}
}
Sorry if I've not formatted this correctly, haven't been on here in so long!
You've made a typo depending on how you want to view it should be either:
//wrong class declaration
public abstract class Input : ScriptableObject
{...}
//correct class declaration (how it is written in the github of the tutorial)
public abstract class InputController : ScriptableObject
{...}
alternatively you could also do
//corrected class declaration in other script
public class PlayerController : Input
However I would advise against that and use the tutorial variant, because Input is already a default Unity class that is used for input devices and you'll just be confusing yourself and the compiler.
I started playing games for the first time in Unity. I get the error in the title. Why could it be? Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.SceneManagement;
public class Quıt : MonoBehaviour
{
{
Application.Quıt();
}
}
It looks like you just need to put it in a method. Also Application.Quit() does not work in the editor.
public class Quit : MonoBehaviour {
public void QuitApplication() {
Application.Quit();
}
}
https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methods
https://docs.unity3d.com/Manual/MobileOptimizationScriptingMethods.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using System.IO;
using UnityEngine.UI;
public class PhotonPlayerSetup : MonoBehaviourPunCallbacks, IInRoomCallbacks
{
private PhotonView PV;
void Awake()
{
PV = GetComponent<PhotonView>();
}
void Start()
{
if(PV.isMine)
{
}
}
}
While using above mentioned code this error appears:
"PhotonView does not contain a definition for isMine and no
accessible extension method isMine accepting a first argument of
type 'PhotonView' could be found (are you missing a using directive or
an assembly reference?)"
Thank you for choosing Photon!
PhotonView.isMine from PUN Classic was renamed to PhotonView.IsMine in PUN 2.
Make sure to check out the Migration Notes.
i'm working on a tower defence for a class exam together with a friend of mine. And i figured i would use "PointToClient" To get the positions of the cursor to send with the tower when ever we want to put it down. But its not quite working. I keep getting the error:
'Vp.PlaceTower'does not contain a definition for 'PointToClient' and no extension method 'PointToClient' accepting a first argument of type 'Vp.PlaceTower' could be found (Are you missing a using directive or an assembly reference?).
The code is as follows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
namespace Vp
{
class PlaceTower : GameWorld
{
private List<Tower> towers = new List<Tower>();
private Point cursorPos;
private Point position;
private Point oldCursorPos;
public void PlaceTower()
{
cursorPos = this.PointToClient(Cursor.Position);
}
}
}
PointToClient is a method that belongs to the class System.Windows.Forms.Control. Does GameWord inherit this class? Your exception is very explanatory.
Make GameWorld inherit Control and you will solve this.