Modify Selector via Script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Crocdent
Posts: 5
Joined: Tue May 07, 2019 11:07 am

Modify Selector via Script

Post 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?
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Modify Selector via Script

Post 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;
User avatar
Crocdent
Posts: 5
Joined: Tue May 07, 2019 11:07 am

Re: Modify Selector via Script

Post by Crocdent »

Works like a charm. Thank you very much!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Modify Selector via Script

Post by Tony Li »

Happy to help!
Post Reply