1
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "BITKits.Extensions.VisualScripting",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:21b0c8d1703a94250bfac916590cea4f",
|
||||
"GUID:ea715009a4efd4c6cbc85be3ae097dd3",
|
||||
"GUID:315d634a9ac6d460a9515f5a56be6311",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"VisualScripting"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65e08b4ab9ec85f46a4d0d30fd3a52d0
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
83
Packages/Common~/Extensions/VisualScripting/VisualEntity.cs
Normal file
83
Packages/Common~/Extensions/VisualScripting/VisualEntity.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Unity.VisualScripting;
|
||||
using BITKit.Entities;
|
||||
namespace BITKit.VisualScript
|
||||
{
|
||||
public abstract class EntityUnit : Unit
|
||||
{
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueInput entity; // Adding the ValueInput variable for myValueA
|
||||
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueInput key; // Adding the ValueInput variable for myValueA
|
||||
[DoNotSerialize] // No need to serialize ports
|
||||
public ValueInput tempValue; // Adding the ValueInput variable for myValueA
|
||||
protected override void Definition()
|
||||
{
|
||||
key = ValueInput<string>("Key");
|
||||
entity = ValueInput<Entity>("Entity");
|
||||
tempValue = ValueInput<string>("TempValue");
|
||||
}
|
||||
}
|
||||
public class GetVariableFromEntity : EntityUnit
|
||||
{
|
||||
|
||||
[DoNotSerialize]
|
||||
public ValueOutput value;
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
value = ValueOutput<string>("Value", GetValue);
|
||||
}
|
||||
string GetValue(Flow flow)
|
||||
{
|
||||
var entity = flow.GetValue<Entity>(this.entity);
|
||||
var key = flow.GetValue<string>(this.key);
|
||||
var value = entity.Get<string>(key);
|
||||
if (tempValue.hasValidConnection)
|
||||
{
|
||||
var _value = flow.GetValue<string>(tempValue);
|
||||
if (String.IsNullOrEmpty(_value) is false)
|
||||
{
|
||||
value = _value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
public class SetVariableForEntity : EntityUnit
|
||||
{
|
||||
[DoNotSerialize]
|
||||
public ControlInput inputTrigger;
|
||||
[DoNotSerialize]
|
||||
public ControlOutput outputTrigger;
|
||||
[DoNotSerialize]
|
||||
public ValueInput value;
|
||||
protected override void Definition()
|
||||
{
|
||||
base.Definition();
|
||||
value = ValueInput<string>("Value");
|
||||
inputTrigger = ControlInput("Input", Input);
|
||||
outputTrigger = ControlOutput("Output");
|
||||
}
|
||||
ControlOutput Input(Flow flow)
|
||||
{
|
||||
var entity = flow.GetValue<Entity>(this.entity);
|
||||
var key = flow.GetValue<string>(this.key);
|
||||
var value = flow.GetValue<string>(this.value);
|
||||
entity.Set<string>(key, value);
|
||||
if (int.TryParse(value, out var _int))
|
||||
{
|
||||
entity.Set<int>(key, _int);
|
||||
}
|
||||
else if (float.TryParse(value, out var _float))
|
||||
{
|
||||
entity.Set<float>(key, _float);
|
||||
}
|
||||
return outputTrigger;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48e6aef8bff8bab48ba47f1e47552dd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user