Weird script behaviour
Posted: 29 Apr 2021 17:28
by juan.delcastillo
Hello. I created a custom command for my project and, since then, my object interaction doesn't work at all
This the custom command script
Code: Select all
using Naninovel;
using Naninovel.Commands;
using UniRx.Async;
using UnityEngine;
[CommandAlias("fadeOut")]
public class FadeOutCommand : Command
{
Animator screenAnimator;
public override UniTask ExecuteAsync(CancellationToken cancellationToken = default)
{
screenAnimator = GameObject.Find("BlackScreen").GetComponent<Animator>();
screenAnimator.Play("FadeOut");
return UniTask.CompletedTask;
}
}
This is the object interaction code
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectInteraction : MonoBehaviour
{
public string scriptName;
public Texture2D magnifierTexture;
[HideInInspector] public GameObject pressedObject;
CameraMovement cameraScript;
delegate void ClickedAction();
event ClickedAction clickEvents;
void Start()
{
cameraScript = GameObject.Find("Main Camera").GetComponent<CameraMovement>();
clickEvents += DirectorScript.directorSingleton.DisableObjectInteraction;
clickEvents += cameraScript.SetDirection;
}
public void OnMouseDown()
{
cameraScript.pressedObject = gameObject;
DirectorScript.directorSingleton.scriptName = scriptName;
clickEvents();
}
void OnMouseEnter()
{
Cursor.SetCursor(magnifierTexture, Vector2.zero, CursorMode.Auto);
}
void OnMouseExit()
{
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
}
Ever since I created the custom command, this script does nothing, even though this script is enabled in all interactive objects. I've also deleted every @fadeOut line and it won't work either
Re: Weird script behaviour
Posted: 30 Apr 2021 10:03
by juan.delcastillo
juan.delcastillo wrote: ↑29 Apr 2021 17:28
Hello. I created a custom command for my project and, since then, my object interaction doesn't work at all
This the custom command script
Code: Select all
using Naninovel;
using Naninovel.Commands;
using UniRx.Async;
using UnityEngine;
[CommandAlias("fadeOut")]
public class FadeOutCommand : Command
{
Animator screenAnimator;
public override UniTask ExecuteAsync(CancellationToken cancellationToken = default)
{
screenAnimator = GameObject.Find("BlackScreen").GetComponent<Animator>();
screenAnimator.Play("FadeOut");
return UniTask.CompletedTask;
}
}
This is the object interaction code
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectInteraction : MonoBehaviour
{
public string scriptName;
public Texture2D magnifierTexture;
[HideInInspector] public GameObject pressedObject;
CameraMovement cameraScript;
delegate void ClickedAction();
event ClickedAction clickEvents;
void Start()
{
cameraScript = GameObject.Find("Main Camera").GetComponent<CameraMovement>();
clickEvents += DirectorScript.directorSingleton.DisableObjectInteraction;
clickEvents += cameraScript.SetDirection;
}
public void OnMouseDown()
{
cameraScript.pressedObject = gameObject;
DirectorScript.directorSingleton.scriptName = scriptName;
clickEvents();
}
void OnMouseEnter()
{
Cursor.SetCursor(magnifierTexture, Vector2.zero, CursorMode.Auto);
}
void OnMouseExit()
{
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
}
Ever since I created the custom command, this script does nothing, even though this script is enabled in all interactive objects. I've also deleted every @fadeOut line and it won't work either
EDIT: I used a backup this time and ObjectInteraction stops working the moment I put @fadeOut in any Nani script. Enabling or disabling ObjectInteraction doesn't work either, both in editor mode and play mode. I checked the assembly information of FadeOutCommand and it refers to Assembly-CSharp.dll, don't know if this means something
Re: Weird script behaviour
Posted: 30 Apr 2021 10:19
by Elringus
Assembly-CSharp is where your custom scripts code is compiled by default (if you're not using asmdefs). The issue is more about general Unity/C# stuff rather than Naninovel.
Re: Weird script behaviour
Posted: 30 Apr 2021 10:41
by juan.delcastillo
Any place where I can start looking for info about it? I mean something more specific
Re: Weird script behaviour
Posted: 30 Apr 2021 12:21
by Elringus
The first step is to isolate what exactly is not behaving as expected; then, in case it's Naninovel-related, feel free to ask here; otherwise, use Unity forum or other related resources.
Re: Weird script behaviour
Posted: 07 May 2021 17:31
by juan.delcastillo
I've solved it. It was a problem of OnMouse event and colliders I forgot that existed