playMaker

Author Topic: Set & Get more then one String (or any other variable) event data/info[SOLVED]  (Read 3746 times)

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
Hi all! I am making a 3D game, huge one and I need some help here. Everything in game is done with Playmaker so I am well familiar with it and I can say it's best tool on the Asset store I purchased. Currently I am working on inventory and I am doing fine out there but need help with some action, when I use SET EVENT DATA and GET EVENT INFO everything is fine but what if I need multiple string variables of the same object for example I need item name, item explanation and maybe some other things so I tried to edit and create new action in order to add multiple data of the same variable but it didn't go very well. Here is the action and what I tried to change:

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
   [ActionCategory(ActionCategory.StateMachine)]
   [Tooltip("Gets info of multiple variables on the last event that caused a state change. See also Set Event Data action.")]
   public class GetMultipleEventInfo : FsmStateAction
   {
      [UIHint(UIHint.Variable)]
      public FsmGameObject sentByGameObject;
      [UIHint(UIHint.Variable)]
      public FsmString fsmName;
      [UIHint(UIHint.Variable)]
      public FsmBool getBoolData;
      [UIHint(UIHint.Variable)]
      public FsmInt getIntData;
      [UIHint(UIHint.Variable)]
      public FsmFloat getFloatData;
      [UIHint(UIHint.Variable)]
      public FsmVector2 getVector2Data;
      [UIHint(UIHint.Variable)]
      public FsmVector3 getVector3Data;
      [UIHint(UIHint.Variable)]
      public FsmString getStringData;
      [UIHint(UIHint.Variable)]
      public FsmString getStringData2;
      [UIHint(UIHint.Variable)]
      public FsmGameObject getGameObjectData;
      [UIHint(UIHint.Variable)]
      public FsmRect getRectData;
      [UIHint(UIHint.Variable)]
      public FsmQuaternion getQuaternionData;
      [UIHint(UIHint.Variable)]
      public FsmMaterial getMaterialData;
      [UIHint(UIHint.Variable)]
      public FsmTexture getTextureData;
      [UIHint(UIHint.Variable)]
      public FsmColor getColorData;
      [UIHint(UIHint.Variable)]
      public FsmObject getObjectData;

      public override void Reset()
      {
         sentByGameObject = null;
         fsmName = null;
         getBoolData = null;
         getIntData = null;
         getFloatData = null;
         getVector2Data = null;
         getVector3Data = null;
         getStringData = null;
         getStringData2 = null;
         getGameObjectData = null;
         getRectData = null;
         getQuaternionData = null;
         getMaterialData = null;
         getTextureData = null;
         getColorData = null;
         getObjectData = null;
      }

      public override void OnEnter()
      {
         if (Fsm.EventData.SentByFsm != null)
         {
            sentByGameObject.Value = Fsm.EventData.SentByFsm.GameObject;
            fsmName.Value = Fsm.EventData.SentByFsm.Name;
         }
         else
         {
            sentByGameObject.Value = null;
            fsmName.Value = "";
         }
         
         getBoolData.Value = Fsm.EventData.BoolData;
         getIntData.Value = Fsm.EventData.IntData;
         getFloatData.Value = Fsm.EventData.FloatData;
         getVector2Data.Value = Fsm.EventData.Vector2Data;
         getVector3Data.Value = Fsm.EventData.Vector3Data;
         getStringData.Value = Fsm.EventData.StringData;
         getStringData2.Value = Fsm.EventData.StringData2;
         getGameObjectData.Value = Fsm.EventData.GameObjectData;
         getRectData.Value = Fsm.EventData.RectData;
         getQuaternionData.Value = Fsm.EventData.QuaternionData;
         getMaterialData.Value = Fsm.EventData.MaterialData;
         getTextureData.Value = Fsm.EventData.TextureData;
         getColorData.Value = Fsm.EventData.ColorData;
         getObjectData.Value = Fsm.EventData.ObjectData;
         
         Finish();
      }
   }
}

But that doesn't seem to work cause I get error Assets/PlayMaker/Actions/GetMultipleEventInfo.cs(81,62): error CS1061: Type `HutongGames.PlayMaker.FsmEventData' does not contain a definition for `StringData2' and no extension method `StringData2' of type `HutongGames.PlayMaker.FsmEventData' could be found (are you missing a using directive or an assembly reference?)

So can you provide me those two action for set event and get event for multiple variable, and to create option to define how much string or any other variables we want to define>?
I think that action would be pretty useful to anyone who use hash tables.

Thanks anyway!
« Last Edit: July 31, 2013, 01:56:20 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 I have a more flexible solution for this:


http://hutonggames.com/playmakerforum/index.php?topic=4296.msg20172#msg20172

with this, you simply add as much variables, and of any types. so the action UI is smaller, and only shows what you need.

bye,

 Jean

Bjakuja

  • Junior Playmaker
  • **
  • Posts: 75
« Last Edit: July 31, 2013, 02:02:29 PM by Bjakuja »