Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Adventure Creator
- * by Chris Burton, 2013-2020
- *
- * "ActionTemplate.cs"
- *
- * This is a blank action template.
- *
- */
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace AC
- {
- [System.Serializable]
- public class ActionChangeFontColor : Action
- {
- // Declare variables here
- public Text mytext;
- public Color mycolor = Color.white;
- public Color fadeColor = Color.black;
- public int constantID;
- public float fadeTime = 2;
- public float fadeStart = 0;
- public GameObject objectToAffect;
- public ActionChangeFontColor ()
- {
- this.isDisplayed = true;
- category = ActionCategory.Custom;
- title = "Change Font Color";
- description = "It changes the font color I guess.";
- }
- override public 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:
- */
- fadeStart = 0;
- if (fadeStart < fadeTime)
- {
- fadeStart += Time.deltaTime * fadeTime;
- mytext.color = Color.Lerp(mycolor, fadeColor, fadeStart);
- }
- 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 ();
- }
- override public void AssignValues ()
- {
- mytext = AssignFile (constantID, mytext);
- }
- #if UNITY_EDITOR
- public override void ShowGUI ()
- {
- mytext = (Text) EditorGUILayout.ObjectField ("Text:", mytext, typeof (Text), false);
- mycolor = (Color) EditorGUILayout.ColorField ("Color:", mycolor);
- constantID = FieldToID (mytext, constantID);
- mytext = IDToField (mytext, constantID, true);
- AfterRunningOption ();
- }
- public override string SetLabel ()
- {
- // (Optional) Return a string used to describe the specific action's job.
- return string.Empty;
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement