#cant drag script
1 messages · Page 1 of 1 (latest)
using System.Collections;
using UnityEngine;
using TMPro;
using UnityEngine.InputSystem;
namespace DialogueSystem
{
public class DialogueBaseClass : MonoBehaviour
{
private PlayerInputActions playerActionAsset;
[SerializeField] private PlayerAction actionsScript;
[SerializeField] private PlayerInput inputScript;
void Awake(){
playerActionAsset = inputScript.playerInputActions;
}
public bool finished {get; private set;} = false;
protected IEnumerator WriteText(string input, TMP_Text textHolder, Color textColor, TMP_FontAsset textFont, float delay, AudioClip sound, float delayBetweenLines){
textHolder.color = textColor;
textHolder.font = textFont;
for(int i = 0; i < input.Length; i++){
textHolder.text += input[i];
SoundManager.instance.PlaySound(sound);
yield return new WaitForSeconds(0.1f);
}
yield return new WaitUntil(() => playerActionAsset.Player.Interact.triggered); //waits for spacebar to be pressd //actionsScript.talk
finished = true;
actionsScript.talk = false;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInput : MonoBehaviour
{
private Player playerScript;
private PlayerAction actionsScript;
private PlayerCollision collisionScript;
private PlayerStateMachine stateMachineScript;
//Set up
public InputAction move, interact; //selects a specific input action
public PlayerInputActions playerInputActions; //Uses our generated input map
public Vector2 moveDirection = Vector2.zero;
void Awake(){
playerScript = GetComponent<Player>();
actionsScript = GetComponent<PlayerAction>();
collisionScript = GetComponent<PlayerCollision>();
stateMachineScript = GetComponent<PlayerStateMachine>();
playerInputActions = new PlayerInputActions();
}
void Start()
{
}
void Update()
{
moveDirection = move.ReadValue<Vector2>();
}
private void OnEnable(){
//Selects 1 input action and enables
move = playerInputActions.Player.Move;
move.Enable();
interact = playerInputActions.Player.Interact;
interact.Enable();
interact.performed += Interact; //Delegates r varibles that hold methods. //When interact is performed, it will trigger this method.
}
private void OnDisable(){
interact.performed -= Interact;
move.Disable();
interact.Disable();
}
public void Interact(InputAction.CallbackContext _context){ //decoupled
if(playerScript.canInteract){
actionsScript.Interact();
}
}
}
And in DialogueBaseClass, if you put your cursor on PlayerInput and press F12, does it open the second script?
it still takes me to the script
Can you expand the PlayerInput on your Player object and screenshot that
Would it be at all possible to record a video of you trying to drag this object into that slot
So, it's taking the object just fine. Then it's setting it to None. But your game isn't running. Seems like you have an editor script?
First off, sanity check, reboot Unity
okay
I just rebooted, it still doesn't work
im so confused...
Maybe the new unity input system doens't allow you to drag that script?
Only thing I can think of is some sort of editor script running in the background that's clearing that field
Both of these scripts are custom, right?
yep
I've dragged this script into other script component slots
but only on the same object
Have you dragged other things onto DialogueBaseClass before successfully?
yea, I added 2 other scripts into it fine
its just this one
imma try getting the script from the game object instead
private PlayerInputActions playerActionAsset;
[SerializeField] private PlayerAction actionsScript;
[SerializeField] private PlayerInput inputScript;
public GameObject gameobject;
void Awake(){
playerActionAsset = inputScript.playerInputActions;
inputScript = gameobject.GetComponent<PlayerInput>();
playerActionAsset = inputScript.playerInputActions;
}```
nah, its impossible
I have no idea whats wrong with it.
I guess try removing both components, then re-adding them
And the one you're trying to drag in
yea, it wont let me 😦
isn't playerinput a default generated C# class ?
no? its mine.
oh :\ thought it was this
No, and through the IDE, I had them check that the PlayerInput that the script is asking for is indeed this class
You can see in the video it doesn't give the 🚫 cursor symbol that it would if there was a type mismatch
a bug ?
yea
It does, and it brings up the object as an option. Then, when clicking on it... nothing
I think its the input system's fault.
Id try regenerate files / reimport assets mayb.
@serene spindle Do this real quick. Make a new script named whatever and just give it this one line:
public PlayerInput input;
Then add this script to that object, and see if you can drag it in then
same thing happens
Yeah I think this might be an honest to god bug in Unity
yikes
probably :<
What was even weirder was that my player could move without a player input component before
I am absolutely stumped.
ty anyways
I would still try reimporting all assets as a last minute ditch attempt
How do you re-import?
Maybe see if anyone at #🖱️┃input-system has any ideas? Or even #archived-code-general, link this thread and tell em I'm punting this one up the chain
doing it now :3
still the same 😦
Imma try copy and paste that script into a new one
HUH
IT FIXED IT?!
WTF
Now im even more confused.
Me: "Script's haunted."
Null: "What?"
Me, loading shotgun: "Script's haunted."
Hmmm...
lmao
I don't think I can name it PlayerInput
scripts gone rogue
I just changed the name back to the original one
and now it won't let me add it
HUH?!
A player input script that won't let me call it "PlayerInput"
Wtf is happening
Oh...
I Think I know
is your action map called player input?
no, its called PlayeInputAction
oh