Advertisement
Guest User

Fungus Custom Command Base

a guest
Dec 18th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Fungus;
  5.  
  6. namespace Fungus
  7. {
  8.     [CommandInfo("Your Custom Commands",
  9.         "Your Custom Command Nr 1",
  10.         "Description of your custom command!")]
  11.  
  12.     [AddComponentMenu("")]
  13.     public class Fungus_YourCustomCommand : Command
  14.     {
  15.         [Tooltip("You could drag a game object here, or some other component")]
  16.         public GameObject object;
  17.         [Tooltip("String/Float/Integer/BooleanData allow for either value entry or setting a variable")]
  18.         public StringData stringData;
  19.         [Tooltip("String/Float/Integer/BooleanVariable require a Fungus variable to be set")]
  20.         [VariableProperty(typeof(IntegerVariable))]
  21.         public IntegerVariable intVar;
  22.  
  23.         private int plusint = 1;
  24.  
  25.         public override void OnEnter()
  26.         { // This is where the magic happens: when this command is reached, everything in here is run.
  27.            
  28.             // This gets you your flowchart, if you need it
  29.             Flowchart thisFlowchart = GetFlowchart();
  30.            
  31.             Debug.Log("This is the object you dragged here: " + object);
  32.             // You can't change the variable data in the Flowchart, only locally
  33.             Debug.Log("This is the string: " + stringData);
  34.             // You can read/write the variable info by appending .Value
  35.             Debug.Log("This is the int before: " + intVar.Value);
  36.             // Now we add our private int variable to it, and then log it again
  37.             intVar.Value +=plusint;
  38.             Debug.Log("This is the int after: " + intVar.Value);
  39.            
  40.             OnWaitComplete();
  41.         }
  42.  
  43.         void OnWaitComplete()
  44.         { // Continue() is what tells the Flowchart the command is finished and needs to continue to the next one
  45.             Continue();
  46.         }
  47.  
  48.         public override Color GetButtonColor()
  49.         { // This lets you set some other colour than just white!
  50.             return new Color32(17, 120, 131, 255);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement