Search Unity

Resolved Bolt can not find my MonoBehaviour script's public method.

Discussion in 'Visual Scripting' started by Ca2didi, Jun 27, 2021.

  1. Ca2didi

    Ca2didi

    Joined:
    Sep 8, 2019
    Posts:
    16
    I'm trying to using Bolt to make sure our team members could participate into our game design. So I set up a test project to find a way to make it. But while I trying to call a Component which attach to a GameObject, I find that any of my public method is out of reach.
    But here is a strange things: only this class could not work properly.

    Here is my snapshot in Bolt:
    upload_2021-6-27_23-24-34.png
    code:
    Code (CSharp):
    1. using UnityEngine;
    2. using Ludiq;
    3.  
    4. public class FightBehaviour : MonoBehaviour
    5. {
    6.     public FightProperty property;
    7.     public IWeapon weapon;
    8.     public Movement movement;
    9.  
    10.     private void Start()
    11.     {
    12.         weapon.EnableSelf(this);
    13.     }
    14.  
    15.     public void CheckAttact()
    16.     {
    17.         if (!weapon.IsAutomaticAttact && Input.GetKeyDown(KeyCode.Return))
    18.         {
    19.             if (weapon.IsNeedRefill) weapon.Fill();
    20.             else if (weapon.IsAllowFire)
    21.                 weapon.Fire(movement.IsForward ? Vector3.right : Vector3.left);
    22.         }
    23.  
    24.     }
    25.  
    26.     public void ChangeWeapon(IWeapon weapon)
    27.     {
    28.         this.weapon.DisableSelf();
    29.         this.weapon = weapon;
    30.         weapon.EnableSelf(this);
    31.     }
    32. }
    33.  
    Thanks if you could help me figure it out!

    My Device and Versions:
    Device: MacBook Air M1 16G+512G
    Unity: 2020.3.12f1c1
    Bolt: 1.4.15
     
  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,068
    Decorate your class with [IncludeInSettings(true)] attribute and after compiling run Tools/Bolt/Build Unit Options. This will expose all public class members to Bolt.

    An alternate way of doing this would be via GUI - Tools/Bolt/Unit Options Wizard. Scroll down, swap from Assemblies to Types tab and add your custom type. Then hit the Regenerate Units button.

    If your custom type is already added in Bolt's unit options via one of the above methods, and you want Bolt to acknowledge any changes made to that type's members, you can run Tools/Bolt/Update Unit Options which is much faster than Build Unit Options.

    When refactoring your code, specifically when renaming something you want to use [RenamedFrom("")] attribute above the thing (could be a class, variable or method) you're renaming to make sure none of the existing nodes in graphs break.
     
    Last edited: Jun 27, 2021
    wenpu86 and haroldo7 like this.
  3. Ca2didi

    Ca2didi

    Joined:
    Sep 8, 2019
    Posts:
    16
    That's work! Thanks