Search Unity

Mirror - SyncVar

Discussion in 'Visual Scripting' started by Welfarecheck, Jun 29, 2021.

  1. Welfarecheck

    Welfarecheck

    Joined:
    Jun 14, 2020
    Posts:
    120
    I need some help with Mirror SyncVar and creating a node to dynamically set/get the variable name like the get/set variable currently in Visual Scripting.

    For the Command/ClientRpc calls this is the node it gives me with the code below. It allows me to use the command by inputs.

    upload_2021-6-29_17-27-27.png

    Command code
    Code (CSharp):
    1.     [Command] // CMD - Sqlite call
    2.     public void CmdSqlite(string Trigger, string SqlQuery, string Database, string ReturnTrigger, GameObject TargetObj)
    3.     {
    4.         CustomEvent.Trigger(gameObject, Trigger, SqlQuery, Database, ReturnTrigger, TargetObj);
    5.     }
    Now, I need a syncvar node using the following code to create a similar node

    Code (CSharp):
    1. using UnityEngine;
    2. using Mirror;
    3. using Unity.VisualScripting;
    4.  
    5. public class SyncVarPlayerEenemy : NetworkBehaviour
    6. {  
    7.     [SyncVar]
    8.     public int Level = 1; // Player Level
    9. }
    Right now, the only thing you can do is get/set the variables one by one and with 400 of them, I'd rather not do that. I need the ability to feed it a string for the name the same as the get/set variables currently work.

    upload_2021-6-29_17-34-39.png

    I'm not a programmer so I'm pretty lost on this one. I'm thinking there has to be an input at the top of the script to pick the syncvar that is called or something along those lines.