#cant drag script

1 messages · Page 1 of 1 (latest)

serene spindle
#
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();
        }
    }
    
}
brazen stone
#

And in DialogueBaseClass, if you put your cursor on PlayerInput and press F12, does it open the second script?

serene spindle
#

No, it opens the same script

brazen stone
#

Oh that's VSCode not VS

#

I have no idea what the "Go to definition" shortcut key is

serene spindle
#

it still takes me to the script

brazen stone
#

Can you expand the PlayerInput on your Player object and screenshot that

serene spindle
brazen stone
#

Would it be at all possible to record a video of you trying to drag this object into that slot

serene spindle
#

okay

#

I've never had this happen before

#

Im so confused

brazen stone
#

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

serene spindle
#

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?

brazen stone
#

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?

serene spindle
#

yep

#

I've dragged this script into other script component slots

#

but only on the same object

brazen stone
#

Have you dragged other things onto DialogueBaseClass before successfully?

serene spindle
#

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.

brazen stone
#

I guess try removing both components, then re-adding them

serene spindle
#

Its just this one script

brazen stone
serene spindle
#

yea, it wont let me 😦

ebon gull
#

isn't playerinput a default generated C# class ?

serene spindle
#

no? its mine.

ebon gull
#

oh :\ thought it was this

brazen stone
#

You can see in the video it doesn't give the 🚫 cursor symbol that it would if there was a type mismatch

serene spindle
#

It doesn't let me drag in from the asset folder though

ebon gull
#

see if shows up

serene spindle
ebon gull
brazen stone
serene spindle
#

I think its the input system's fault.

ebon gull
#

Id try regenerate files / reimport assets mayb.

brazen stone
#

@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

serene spindle
#

same thing happens

brazen stone
#

Yeah I think this might be an honest to god bug in Unity

serene spindle
#

yikes

#

probably :<

#

What was even weirder was that my player could move without a player input component before

brazen stone
#

I am absolutely stumped.

serene spindle
#

ty anyways

ebon gull
#

I would still try reimporting all assets as a last minute ditch attempt

serene spindle
#

How do you re-import?

brazen stone
ebon gull
#

worth a shot

serene spindle
#

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.

ebon gull
#

bad meta?

#

who knos

brazen stone
serene spindle
#

Hmmm...

ebon gull
#

lmao

serene spindle
#

I don't think I can name it PlayerInput

ebon gull
#

scripts gone rogue

serene spindle
#

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

ebon gull
#

is your action map called player input?

serene spindle
#

no, its called PlayeInputAction

ebon gull
#

oh

serene spindle
#

Maybe its getting confused with the input system component

#

cuz it has the same name

ebon gull
#

could be. iirc it was PlayerInput somewhere b4

#

but who know

#

it

#

haunted