Page 1 of 1

Modify Selector via Script

Posted: Tue Jun 11, 2019 8:56 am
by Crocdent
Hello, I am currently trying to modify the properties of the Selector attached to my player during gameplay. I need to change its SelectAt from Screen Center to Mouse Position directly from a script. I though this could be possible, as I can access Selector.SelectAt, however I cannot find a way to modify it, because it takes a specific type of variable (PixelCrushers.DialogueSystem.Selector.SelectAt).

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;

public class PatientExam : MonoBehaviour
{
    public GameObject Cam;
    public GameObject Player;

    void Start()
    {
        Debug.Log("Exam Start");
        Cam.GetComponent<CamZoom>().ZoomIn();
        Cursor.lockState = CursorLockMode.None;
        
        //This is where I want to change the SelectAt property
        //Player object has the Selector component, and it's recognized by Visual Studio
        Player.GetComponent<Selector>().selectAt = "Mouse Position";
    }

    
}
Does anyone know how to achieve this? If not, another way to change SelectAt during playtime?

Re: Modify Selector via Script

Posted: Tue Jun 11, 2019 8:59 am
by Tony Li
Hi!

Instead of this:

Code: Select all

Player.GetComponent<Selector>().selectAt = "Mouse Position";
use this:

Code: Select all

Player.GetComponent<Selector>().selectAt = Selector.SelectAt.MousePosition;

Re: Modify Selector via Script

Posted: Tue Jun 11, 2019 9:09 am
by Crocdent
Works like a charm. Thank you very much!

Re: Modify Selector via Script

Posted: Tue Jun 11, 2019 9:12 am
by Tony Li
Happy to help!