Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

Edit action variables in BT editor
  • maeslamaesla December 2011
    It would be nice changing own action variable values inside the editor BT, just like you do in yours primitive actions
  • prime January 2
    We're still working on solutions for that type of functionality. We get away with it in our primitives because we build custom editor scripts for our primitive nodes. We don't have a way to do that for user defined variables (yet).
  • helmers January 8
    I second this request. This is quite essential to reuse own actions. Otherwise we have to derive own classes for each use case or have to use lots off Assignments to provide the data via the ActionContext.
  • robintheiladerobintheilade February 13
    As far as I know the value of custom attributes that you put on your custom action are not even possible to access within the code. If I'm right, the first logical step would be to support that. Then the GUI editing of the values can come second (but still a nice feature though).

    You (Rival{Theory}) could simply make your code iterate over each of the attributes on the xml node and use reflection to see if the action has a public field with the same name and assign the value to it.

    pseudo:
    var action = new SomeonesCustomAction();
    var type = action.GetType();
    foreach(var attribute in node.Attributes)
    {
    var field = type.GetField(attribute.Name);
    if(field!=null)
    {
    field.SetValue(action, attribute.Value);
    }
    }

    A simple string only support would suffice. But if you're wanna go the extra mile you could allow use of the TypeConverter functionality.

    It's as simple as that.
  • siflandolly February 13
    @robintheilade

    you can currently do something like this with code:
    agent.actionContext.SetContextItem("myVariable", 1f);

    or if you're on the GameObject level:

    RAINAgent myRainAgent = myGameObj.GetComponent< RAINAgent >();

    myRainAgent.Agent.actionContext.SetContextItem("myVariable", 1f);


    Not sure if that answers your question at all?
  • robintheiladerobintheilade February 13
    @siflandolly

    Thank you for your suggestion for a workaround. While we're discussing workarounds the workaround I have in mind is to create a MonoBehaviour that acts as a configuration for a custom action and add that MonoBehaviour to the GameObject in question in that way enabling GUI editing of the values for my custom action. This configuration should then be accessable through the Agent.Avatar.GetComponent() method.

    While both workarounds should work, I still think that the value of the attributes for a custom action should somehow be assigned the custom action whenever possible, GUI support or not.
  • @robintheilade

    Thanks that's a great workaround as well.