Adventure Creator Wikia

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 8: Line 8:
 
The variables will now be linked - so changing its value in one asset will update the value of its associated variable in the other.
 
The variables will now be linked - so changing its value in one asset will update the value of its associated variable in the other.
   
BoltVariableLink.cs<syntaxhighlight lang="csharp">
+
BoltVariableLink.cs
using System.Collections;
+
using System.Collections;<br>
using System.Collections.Generic;
+
using System.Collections.Generic;<br>
using UnityEngine;
+
using UnityEngine;<br>
using AC;
+
using AC;<br>
using Bolt;
+
using Bolt;<br>
  +
<br>
 
public class BoltVariableLink : MonoBehaviour
+
public class BoltVariableLink : MonoBehaviour<br>
  +
{<br>
{
 
  +
<br>
 
[SerializeField] BoltVarLink[] boltVarLinks;
+
[SerializeField] BoltVarLink[] boltVarLinks;<br>
  +
<br>
 
  +
<br>
private void OnEnable ()
 
  +
private void OnEnable ()<br>
{
 
  +
{<br>
EventManager.OnDownloadVariable += OnDownload;
 
EventManager.OnUploadVariable += OnUpload;
+
EventManager.OnDownloadVariable += OnDownload;<br>
  +
EventManager.OnUploadVariable += OnUpload;<br>
}
 
  +
}<br>
 
  +
<br>
private void OnDisable ()
 
  +
<br>
{
 
  +
private void OnDisable ()<br>
EventManager.OnDownloadVariable -= OnDownload;
 
  +
{<br>
EventManager.OnUploadVariable -= OnUpload;
 
  +
EventManager.OnDownloadVariable -= OnDownload;<br>
}
 
  +
EventManager.OnUploadVariable -= OnUpload;<br>
 
  +
}<br>
private void OnDownload (GVar variable, AC.Variables variables)
 
  +
<br>
{
 
  +
<br>
foreach (BoltVarLink boltVarLink in boltVarLinks)
 
  +
private void OnDownload (GVar variable, AC.Variables variables)<br>
{
 
  +
{<br>
boltVarLink.Download (variable);
 
  +
foreach (BoltVarLink boltVarLink in boltVarLinks)<br>
}
 
  +
{<br>
}
 
  +
boltVarLink.Download (variable);<br>
 
  +
}<br>
private void OnUpload (GVar variable, AC.Variables variables)
 
  +
}<br>
{
 
  +
<br>
foreach (BoltVarLink boltVarLink in boltVarLinks)
 
  +
<br>
{
 
  +
private void OnUpload (GVar variable, AC.Variables variables)<br>
boltVarLink.Upload (variable);
 
  +
{<br>
}
 
  +
foreach (BoltVarLink boltVarLink in boltVarLinks)<br>
}
 
  +
{<br>
 
  +
boltVarLink.Upload (variable);<br>
 
  +
}<br>
[System.Serializable] private class BoltVarLink
 
  +
}<br>
{
 
  +
<br>
 
  +
<br>
[SerializeField] private string boltVariableName = "";
 
  +
[System.Serializable] private class BoltVarLink<br>
[SerializeField] private BoltVariableType boltVariableType = BoltVariableType.Application;
 
  +
{<br>
private enum BoltVariableType { Application, Saved };
 
  +
<br>
[SerializeField] private int acVariableID = 0;
 
  +
[SerializeField] private string boltVariableName = "";<br>
 
  +
[SerializeField] private BoltVariableType boltVariableType = BoltVariableType.Application;<br>
public void Download (GVar variable)
 
  +
private enum BoltVariableType { Application, Saved };<br>
{
 
  +
[SerializeField] private int acVariableID = 0;<br>
if (!string.IsNullOrEmpty (boltVariableName) && variable.id == acVariableID)
 
  +
<br>
{
 
  +
<br>
if (boltVariableType == BoltVariableType.Application)
 
  +
public void Download (GVar variable)<br>
{
 
  +
{<br>
switch (variable.type)
 
  +
if (!string.IsNullOrEmpty (boltVariableName) && variable.id == acVariableID)<br>
{
 
  +
{<br>
case VariableType.Integer:
 
  +
if (boltVariableType == BoltVariableType.Application)<br>
case VariableType.PopUp:
 
  +
{<br>
variable.IntegerValue = (int) Bolt.Variables.Application.Get (boltVariableName);
 
  +
switch (variable.type)<br>
break;
 
  +
{<br>
 
case VariableType.Boolean:
+
case VariableType.Integer:<br>
  +
case VariableType.PopUp:<br>
variable.BooleanValue = (bool) Bolt.Variables.Application.Get (boltVariableName);
 
  +
variable.IntegerValue = (int) Bolt.Variables.Application.Get (boltVariableName);<br>
break;
 
  +
break;<br>
 
  +
<br>
case VariableType.Float:
 
  +
case VariableType.Boolean:<br>
variable.FloatValue = (float) Bolt.Variables.Application.Get (boltVariableName);
 
  +
variable.BooleanValue = (bool) Bolt.Variables.Application.Get (boltVariableName);<br>
break;
 
  +
break;<br>
 
  +
case VariableType.String:
 
  +
<br>
variable.TextValue = (string) Bolt.Variables.Application.Get (boltVariableName);
 
  +
case VariableType.Float:<br>
break;
 
  +
variable.FloatValue = (float) Bolt.Variables.Application.Get (boltVariableName);<br>
 
  +
break;<br>
case VariableType.Vector3:
 
  +
<br>
variable.Vector3Value = (Vector3) Bolt.Variables.Application.Get (boltVariableName);
 
  +
case VariableType.String:<br>
break;
 
  +
variable.TextValue = (string) Bolt.Variables.Application.Get (boltVariableName);<br>
 
default:
+
break;<br>
  +
<br>
break;
 
  +
case VariableType.Vector3:<br>
}
 
  +
variable.Vector3Value = (Vector3) Bolt.Variables.Application.Get (boltVariableName);<br>
}
 
  +
break;<br>
else if (boltVariableType == BoltVariableType.Saved)
 
{
+
}<br>
  +
}<br>
switch (variable.type)
 
  +
else if (boltVariableType == BoltVariableType.Saved)<br>
{
 
  +
{<br>
case VariableType.Integer:
 
  +
switch (variable.type)<br>
case VariableType.PopUp:
 
  +
{<br>
variable.IntegerValue = (int) Bolt.Variables.Saved.Get (boltVariableName);
 
  +
case VariableType.Integer:<br>
break;
 
  +
case VariableType.PopUp:<br>
 
  +
variable.IntegerValue = (int) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.Boolean:
 
  +
break;<br>
variable.BooleanValue = (bool) Bolt.Variables.Saved.Get (boltVariableName);
 
  +
<br>
break;
 
  +
case VariableType.Boolean:<br>
 
  +
variable.BooleanValue = (bool) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.Float:
 
  +
break;<br>
variable.FloatValue = (float) Bolt.Variables.Saved.Get (boltVariableName);
 
break;
+
  +
<br>
 
case VariableType.String:
+
case VariableType.Float:<br>
variable.TextValue = (string) Bolt.Variables.Saved.Get (boltVariableName);
+
variable.FloatValue = (float) Bolt.Variables.Saved.Get (boltVariableName);<br>
break;
+
break;<br>
  +
<br>
 
case VariableType.Vector3:
+
case VariableType.String:<br>
variable.Vector3Value = (Vector3) Bolt.Variables.Saved.Get (boltVariableName);
+
variable.TextValue = (string) Bolt.Variables.Saved.Get (boltVariableName);<br>
break;
+
break;<br>
  +
<br>
 
  +
case VariableType.Vector3:<br>
default:
 
  +
variable.Vector3Value = (Vector3) Bolt.Variables.Saved.Get (boltVariableName);<br>
break;
 
}
+
break;<br>
}
+
}<br>
}
+
}<br>
}
+
}<br>
  +
}<br>
 
  +
<br>
public void Upload (GVar variable)
 
  +
<br>
{
 
  +
public void Upload (GVar variable)<br>
AC.KickStarter.stateHandler.IsPaused ();
 
  +
{<br>
if (!string.IsNullOrEmpty (boltVariableName) && variable.id == acVariableID)
 
  +
if (!string.IsNullOrEmpty (boltVariableName) && variable.id == acVariableID)<br>
{
 
  +
{<br>
if (boltVariableType == BoltVariableType.Application)
 
  +
if (boltVariableType == BoltVariableType.Application)<br>
{
 
  +
{<br>
switch (variable.type)
 
  +
switch (variable.type)<br>
{
 
  +
{<br>
case VariableType.Integer:
 
case VariableType.PopUp:
+
case VariableType.Integer:<br>
  +
case VariableType.PopUp:<br>
Bolt.Variables.Application.Set (boltVariableName, variable.IntegerValue);
 
  +
Bolt.Variables.Application.Set (boltVariableName, variable.IntegerValue);<br>
break;
 
  +
break;<br>
 
  +
<br>
case VariableType.Boolean:
 
  +
case VariableType.Boolean:<br>
Bolt.Variables.Application.Set (boltVariableName, variable.BooleanValue);
 
  +
Bolt.Variables.Application.Set (boltVariableName, variable.BooleanValue);<br>
break;
 
  +
break;<br>
 
  +
<br>
case VariableType.Float:
 
  +
case VariableType.Float:<br>
Bolt.Variables.Application.Set (boltVariableName, variable.FloatValue);
 
  +
Bolt.Variables.Application.Set (boltVariableName, variable.FloatValue);<br>
break;
 
  +
break;<br>
 
  +
<br>
case VariableType.String:
 
  +
case VariableType.String:<br>
Bolt.Variables.Application.Set (boltVariableName, variable.TextValue);
 
  +
Bolt.Variables.Application.Set (boltVariableName, variable.TextValue);<br>
break;
 
  +
break;<br>
 
  +
<br>
case VariableType.Vector3:
 
  +
case VariableType.Vector3:<br>
Bolt.Variables.Application.Set (boltVariableName, variable.Vector3Value);
 
  +
Bolt.Variables.Application.Set (boltVariableName, variable.Vector3Value);<br>
break;
 
  +
break;<br>
 
default:
+
}<br>
break;
+
}<br>
  +
else if (boltVariableType == BoltVariableType.Saved)<br>
}
 
}
+
{<br>
  +
switch (variable.type)<br>
else if (boltVariableType == BoltVariableType.Saved)
 
{
+
{<br>
  +
case VariableType.Integer:<br>
switch (variable.type)
 
  +
case VariableType.PopUp:<br>
{
 
  +
variable.IntegerValue = (int) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.Integer:
 
  +
break;<br>
case VariableType.PopUp:
 
  +
<br>
Bolt.Variables.Saved.Set (boltVariableName, variable.IntegerValue);
 
  +
case VariableType.Boolean:<br>
break;
 
  +
variable.BooleanValue = (bool) Bolt.Variables.Saved.Get (boltVariableName);<br>
 
  +
break;<br>
case VariableType.Boolean:
 
  +
Bolt.Variables.Saved.Set (boltVariableName, variable.BooleanValue);
 
  +
<br>
break;
 
  +
case VariableType.Float:<br>
 
  +
variable.FloatValue = (float) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.Float:
 
  +
break;<br>
Bolt.Variables.Saved.Set (boltVariableName, variable.FloatValue);
 
  +
<br>
break;
 
  +
case VariableType.String:<br>
 
  +
variable.TextValue = (string) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.String:
 
  +
break;<br>
Bolt.Variables.Saved.Set (boltVariableName, variable.TextValue);
 
  +
<br>
break;
 
  +
case VariableType.Vector3:<br>
 
  +
variable.Vector3Value = (Vector3) Bolt.Variables.Saved.Get (boltVariableName);<br>
case VariableType.Vector3:
 
  +
break;<br>
Bolt.Variables.Saved.Set (boltVariableName, variable.Vector3Value);
 
break;
+
}<br>
  +
}<br>
 
  +
}<br>
default:
 
  +
}<br>
break;
 
  +
<br>
}
 
}
+
}<br>
  +
<br>
}
 
}
+
}
 
}
 
 
}
 
</syntaxhighlight>
 
 
[[Category:Integrations]]
 
[[Category:Integrations]]

Please note that all contributions to the Adventure Creator Wikia are considered to be released under the CC-BY-SA

Cancel Editing help (opens in new window)