Script player isn't playing anything
I'm using a DirectorScript to declare a script player variable so the interactive objects of my scene play a certain script when they are clicked, through a C# script called ObjectInteraction. After a while, none of the interactive objects worked because ObjectInteraction couldn't find any scripts being played on the script player. The Unity service is active on script but no Nani scripts are being played
This is DirectorScript:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Naninovel;
using System;
public class DirectorScript : MonoBehaviour
{
public IScriptPlayer scriptPlayer = Engine.GetService<IScriptPlayer>();
}
void Update() {
Debug.Log(scriptPlayer.PlayedScript.Name);
}
This one is ObjectInteraction:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Naninovel;
public class ObjectInteraction : MonoBehaviour
{
public string scriptName;
DirectorScript directorScript;
public Texture2D magnifierTexture;
void Start()
{
directorScript = FindObjectOfType<DirectorScript>();
}
public void OnMouseDown()
{
directorScript.scriptPlayer.PreloadAndPlayAsync(scriptName);
}
void OnMouseEnter()
{
Cursor.SetCursor(magnifierTexture, Vector2.zero, CursorMode.Auto);
}
void OnMouseExit()
{
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
}
I attach this script to every interactive object and put the name of the script each one has to play
I've tried constantly initializing scriptPlayer but, as expected, the problem is that no Nani scripts are played. I've also checked Script Resources and all scripts are there, they are named correctly and there are no void resources