Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Resolved Handle Bolt Variables with C# script

Discussion in 'Visual Scripting' started by SPNK78, Apr 7, 2021.

  1. SPNK78

    SPNK78

    Joined:
    Mar 8, 2021
    Posts:
    4
    Hello,

    I want to update my Bolt variables with a C# script (https://docs.unity3d.com/bolt/1.4/manual/bolt-variables-api.html)

    I tried this simple script to update a Scene Variable :


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Photon.Pun;
    5. using Bolt;
    6. using Ludiq;
    7.  
    8.  
    9. public class ModifyVariable : MonoBehaviour
    10. {
    11.  
    12.     void Start()
    13.     {
    14.  
    15.         Variables.Scene.Set("Health", 100);
    16.  
    17.      }
    18. }
    But get the compilation error :
    Assets\VariableBolt.cs(15,19): error CS0119: 'Variables.Scene(Scene?)' is a method, which is not valid in the given context


    What did I miss to make this work?

    Thanks
     
  2. SPNK78

    SPNK78

    Joined:
    Mar 8, 2021
    Posts:
    4
    Hello,

    I finally succeded by myself, here is whjat it works for me if someone need :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. //using Photon.Pun;
    5. using Bolt;
    6. //using Ludiq;
    7.  
    8.  
    9.  
    10. public class VariableBolt : MonoBehaviour
    11. {
    12.  
    13.     // Object init if need to handle Object Variable
    14.     private GameObject exampleOne;
    15.     private void Start()
    16.     {
    17.  
    18.         /*Handle Scene Variables - both works */
    19.  
    20.         //Variables.ActiveScene.Set("Health", 100);
    21.         // Variables.Scene(gameObject).Set("Health", 100);
    22.  
    23.         /*Handle Object variables*/
    24.         exampleOne = GameObject.Find("ObjectName");
    25.         Variables.Object(exampleOne).Set("Health", 100);
    26.     }
    27. }
     
    ericb_unity likes this.
unityunity