playMaker

Author Topic: help with action code[SOLVED]  (Read 1289 times)

cel

  • Full Member
  • ***
  • Posts: 132
help with action code[SOLVED]
« on: December 23, 2019, 07:03:17 AM »
hi,
I have a little problem with some actions i'm making to interact with game creator.

I have the following code:

Code: [Select]
using UnityEngine;
using System.Collections;
using GameCreator.Variables;
using HutongGames.PlayMaker;

namespace HutongGames.PlayMaker.Actions

{
    [ActionCategory("Game Creator")]
    [Tooltip("Get a GameCreator local bool Variable value to PlayMaker.")]
    public class GetGameCreatorLocalBoolValue : FsmStateAction
    {

        [RequiredField]
        //Game Creator object with the local variable
        [Tooltip("Game object that contains GameCreator local bool variable.")]
        public FsmGameObject gameCreatorObject;

        [Tooltip("Look for GameCreator variable bool in game object's children.")]
        public bool lookInObjectChildren;

        [RequiredField]
        //Game Creator name (bool) to import from
        [Tooltip("Name of the GameCreator local bool variable")]
        public FsmString gcBoolName;

        [RequiredField]
        //Choose which PlayMaker bool to import value to
        [Tooltip("Store the GameCreator bool variable in a Playmaker bool variable")]
        public FsmBool StoreValue;

        public bool everyFrame;


        //Declare float variable
       private bool var;


        public override void Reset()
        {
            //Reset
            StoreValue = null;
            gcBoolName = null;
            gameCreatorObject = null;
            lookInObjectChildren = false;
            everyFrame = false;

        }

        public override void OnEnter()

        {
            GetBool();
           
            if (!everyFrame)
            {
                Finish();
            }

        }



        //Get variable function from Game Creator
        public bool GetVariable()
       
        {
         
            object result = VariablesManager.GetLocal(gameCreatorObject.Value, gcBoolName.Value, lookInObjectChildren);
            return (bool)result;
         
           
        }

       
        public override void OnUpdate()
        {
           
            //Call get function and save to variable var     
            GetBool();

        }
        private void GetBool()
        {
            if (gameCreatorObject == null) return;

            if (StoreValue == null) return;
           
            GetVariable();
            var = GetVariable();
            StoreValue.Value = var;
        }

    }
   
}


everything works just fine, but the action has a little something that is bothering me and I can't get rid of it. The store value should only list the variables, not the tick box, How do I get rid of it? please see the picture attached

any help appreciated,

thanks
« Last Edit: December 23, 2019, 08:00:27 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: help with action code
« Reply #1 on: December 23, 2019, 08:00:16 AM »
Hi,

 very good question, check out other actions that do what you expect and try to learn from them ( that's how I do most actions, but copying pasting from existing)

you'll need to put an attribute [UIHint(UIHint.Variable)] above that declaration and it will switch to the variable only dropdown.

Bye,

 Jean

cel

  • Full Member
  • ***
  • Posts: 132
Re: help with action code[SOLVED]
« Reply #2 on: December 23, 2019, 08:11:45 AM »
It works, thanks jean