Hi,
So, I have this Custom ACtion Script you helped me with, but it changes the Wait cursor for all cutscenes, and instead I would like this just to change to a different Wait cursor when the speech is played.
How do I change this to make this happen?
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AC
{
[System.Serializable]
public class ActionSetWaitCursor : Action
{
public override ActionCategory Category { get { return ActionCategory.Custom; }}
public override string Title { get { return "Set wait cursor"; }}
public Texture2D newTexture;
public override float Run ()
{
KickStarter.cursorManager.waitIcon.ReplaceTexture (newTexture);
return 0f;
}
public override void Skip ()
{
Run ();
}
#if UNITY_EDITOR
public override void ShowGUI ()
{
newTexture = (Texture2D) EditorGUILayout.ObjectField ("New cursor texture:", newTexture, typeof (Texture2D), false);
}
#endif
}
}
I already have a Custom Action that sets the WAIT cursor to a scene dependent Wait cursor using this script that I use as a custom action before using the above custom action:
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace AC
{
[System.Serializable]
public class ChangeCursorsAction : Action
{
// Declare properties here
public override ActionCategory Category { get { return ActionCategory.Custom; } }
public override string Title { get { return "Switch Cursor Textures"; } }
public override string Description { get { return "This switches the cursor textures"; } }
// Declare variables here
public Texture2D _newMainPointerTexture;
public Texture2D _newWaitTexture;
public Texture2D _newWalkTexture;
public Texture2D _newUseTexture;
public Texture2D _newTalkTexture;
public Texture2D _newLookTexture;
public Texture2D _newPickUpTexture;
public Texture2D _newExitTexture;
public Texture2D _newExitUpTexture;
public override float Run()
{
/*
* This function is called when the action is performed.
*
* The float to return is the time that the game
* should wait before moving on to the next action.
* Return 0f to make the action instantenous.
*
* For actions that take longer than one frame,
* you can return "defaultPauseTime" to make the game
* re-run this function a short time later. You can
* use the isRunning boolean to check if the action is
* being run for the first time, eg:
*/
if (_newMainPointerTexture != null)
{
AC.KickStarter.cursorManager.pointerIcon.texture = _newMainPointerTexture;
}
if (_newWalkTexture != null)
{
AC.KickStarter.cursorManager.waitIcon.texture = _newWaitTexture;
}
if (_newWalkTexture != null)
{
AC.KickStarter.cursorManager.walkIcon.texture = _newWalkTexture;
}
if (_newUseTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(0).texture = _newUseTexture;
}
if (_newTalkTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(1).texture = _newTalkTexture;
}
if (_newLookTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(2).texture = _newLookTexture;
}
if (_newPickUpTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(3).texture = _newPickUpTexture;
}
if (_newExitTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(4).texture = _newExitTexture;
}
if (_newExitUpTexture != null)
{
AC.KickStarter.cursorManager.GetCursorIconFromID(5).texture = _newExitUpTexture;
}
if (!isRunning)
{
isRunning = true;
return defaultPauseTime;
}
else
{
isRunning = false;
return 0f;
}
}
public override void Skip()
{
/*
* This function is called when the Action is skipped, as a
* result of the player invoking the "EndCutscene" input.
*
* It should perform the instructions of the Action instantly -
* regardless of whether or not the Action itself has been run
* normally yet. If this method is left blank, then skipping
* the Action will have no effect. If this method is removed,
* or if the Run() method call is left below, then skipping the
* Action will cause it to run itself as normal.
*/
Run();
}
#if UNITY_EDITOR
public override void ShowGUI()
{
// Action-specific Inspector GUI code here
_newMainPointerTexture = (Texture2D)EditorGUILayout.ObjectField("Main Texture:", _newMainPointerTexture, typeof(Texture2D), true);
_newWaitTexture = (Texture2D)EditorGUILayout.ObjectField("Wait Texture:", _newWaitTexture, typeof(Texture2D), true);
_newWalkTexture = (Texture2D)EditorGUILayout.ObjectField("Walk Texture:", _newWalkTexture, typeof(Texture2D), true);
_newUseTexture = (Texture2D)EditorGUILayout.ObjectField("Use Texture:", _newUseTexture, typeof(Texture2D), true);
_newTalkTexture = (Texture2D)EditorGUILayout.ObjectField("Talk Texture:", _newTalkTexture, typeof(Texture2D), true);
_newLookTexture = (Texture2D)EditorGUILayout.ObjectField("Look Texture:", _newLookTexture, typeof(Texture2D), true);
_newPickUpTexture = (Texture2D)EditorGUILayout.ObjectField("PickUp Texture:", _newPickUpTexture, typeof(Texture2D), true);
_newExitTexture = (Texture2D)EditorGUILayout.ObjectField("Exit Texture:", _newExitTexture, typeof(Texture2D), true);
_newExitUpTexture = (Texture2D)EditorGUILayout.ObjectField("Exit Up Texture:", _newExitUpTexture, typeof(Texture2D), true);
}
public override string SetLabel()
{
// (Optional) Return a string used to describe the specific action's job.
return string.Empty;
}
#endif
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
As an Action, it'll only take effect when you call it - if you want it to run whenever speech plays, you can place it in an ActionList that's set to run at the moment speech plays:
ok thanks, but forgive my stupidity, do i need to turn this into a custom action then? HOw do i place it in an Action List if it is just a script?
The script can be used to call ActionLists when speech starts and stops - you can use it to run your custom Actions from there.
Sorry, I don't quite understand how I 'call the ActionLists when speech starts and stops'.
Attach the script to an object in your scene and you'll see fields to assign ActionLists to in its Inspector.
works perfectly! THANKS CHRIS!