|
|
|
// This code is part of the Fungus library (https://github.com/snozbot/fungus)
|
|
|
|
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
|
|
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
namespace Fungus.EditorUtils
|
|
|
|
{
|
|
|
|
[CustomEditor (typeof(Variable), true)]
|
|
|
|
public class VariableEditor : CommandEditor
|
|
|
|
{
|
|
|
|
public override void OnEnable()
|
|
|
|
{
|
|
|
|
base.OnEnable();
|
|
|
|
|
|
|
|
Variable t = target as Variable;
|
|
|
|
t.hideFlags = HideFlags.HideInInspector;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static VariableInfoAttribute GetVariableInfo(System.Type variableType)
|
|
|
|
{
|
|
|
|
object[] attributes = variableType.GetCustomAttributes(typeof(VariableInfoAttribute), false);
|
|
|
|
foreach (object obj in attributes)
|
|
|
|
{
|
|
|
|
VariableInfoAttribute variableInfoAttr = obj as VariableInfoAttribute;
|
|
|
|
if (variableInfoAttr != null)
|
|
|
|
{
|
|
|
|
return variableInfoAttr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void VariableField(SerializedProperty property,
|
|
|
|
GUIContent label,
|
|
|
|
Flowchart flowchart,
|
|
|
|
string defaultText,
|
|
|
|
Func<Variable, bool> filter,
|
|
|
|
Func<string, int, string[], int> drawer = null)
|
|
|
|
{
|
|
|
|
List<string> variableKeys = new List<string>();
|
|
|
|
List<Variable> variableObjects = new List<Variable>();
|
|
|
|
|
|
|
|
variableKeys.Add(defaultText);
|
|
|
|
variableObjects.Add(null);
|
|
|
|
|
|
|
|
List<Variable> variables = flowchart.Variables;
|
|
|
|
int index = 0;
|
|
|
|
int selectedIndex = 0;
|
|
|
|
|
|
|
|
Variable selectedVariable = property.objectReferenceValue as Variable;
|
|
|
|
|
|
|
|
// When there are multiple Flowcharts in a scene with variables, switching
|
|
|
|
// between the Flowcharts can cause the wrong variable property
|
|
|
|
// to be inspected for a single frame. This has the effect of causing private
|
|
|
|
// variable references to be set to null when inspected. When this condition
|
|
|
|
// occurs we just skip displaying the property for this frame.
|
|
|
|
if (selectedVariable != null &&
|
|
|
|
selectedVariable.gameObject != flowchart.gameObject &&
|
|
|
|
selectedVariable.Scope == VariableScope.Private)
|
|
|
|
{
|
|
|
|
property.objectReferenceValue = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (Variable v in variables)
|
|
|
|
{
|
|
|
|
if (filter != null)
|
|
|
|
{
|
|
|
|
if (!filter(v))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variableKeys.Add(v.Key);
|
|
|
|
variableObjects.Add(v);
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
if (v == selectedVariable)
|
|
|
|
{
|
|
|
|
selectedIndex = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Flowchart> fsList = Flowchart.CachedFlowcharts;
|
|
|
|
foreach (Flowchart fs in fsList)
|
|
|
|
{
|
|
|
|
if (fs == flowchart)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Variable> publicVars = fs.GetPublicVariables();
|
|
|
|
foreach (Variable v in publicVars)
|
|
|
|
{
|
|
|
|
if (filter != null)
|
|
|
|
{
|
|
|
|
if (!filter(v))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variableKeys.Add(fs.name + "/" + v.Key);
|
|
|
|
variableObjects.Add(v);
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
if (v == selectedVariable)
|
|
|
|
{
|
|
|
|
selectedIndex = index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drawer == null)
|
|
|
|
{
|
|
|
|
selectedIndex = EditorGUILayout.Popup(label.text, selectedIndex, variableKeys.ToArray());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
selectedIndex = drawer(label.text, selectedIndex, variableKeys.ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
property.objectReferenceValue = variableObjects[selectedIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(VariablePropertyAttribute))]
|
|
|
|
public class VariableDrawer : PropertyDrawer
|
|
|
|
{
|
|
|
|
|
|
|
|
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
|
|
|
|
{
|
|
|
|
VariablePropertyAttribute variableProperty = attribute as VariablePropertyAttribute;
|
|
|
|
if (variableProperty == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.BeginProperty(position, label, property);
|
|
|
|
|
|
|
|
// Filter the variables by the types listed in the VariableProperty attribute
|
|
|
|
Func<Variable, bool> compare = v =>
|
|
|
|
{
|
|
|
|
if (v == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (variableProperty.VariableTypes.Length == 0)
|
|
|
|
{
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
var compatChecker = property.serializedObject.targetObject as ICollectionCompatible;
|
|
|
|
if (compatChecker != null)
|
|
|
|
{
|
|
|
|
return compatChecker.IsVarCompatibleWithCollection(v, variableProperty.compatibleVariableName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return variableProperty.VariableTypes.Contains<System.Type>(v.GetType());
|
|
|
|
};
|
|
|
|
|
|
|
|
VariableEditor.VariableField(property,
|
|
|
|
label,
|
|
|
|
FlowchartWindow.GetFlowchart(),
|
|
|
|
variableProperty.defaultText,
|
|
|
|
compare,
|
|
|
|
(s,t,u) => (EditorGUI.Popup(position, s, t, u)));
|
|
|
|
|
|
|
|
EditorGUI.EndProperty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class VariableDataDrawer<T> : PropertyDrawer where T : Variable
|
|
|
|
{
|
|
|
|
|
|
|
|
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label)
|
|
|
|
{
|
|
|
|
EditorGUI.BeginProperty(position, label, property);
|
|
|
|
|
|
|
|
// The variable reference and data properties must follow the naming convention 'typeRef', 'typeVal'
|
|
|
|
|
|
|
|
VariableInfoAttribute typeInfo = VariableEditor.GetVariableInfo(typeof(T));
|
|
|
|
if (typeInfo == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
string propNameBase = typeInfo.VariableType;
|
|
|
|
propNameBase = Char.ToLowerInvariant(propNameBase[0]) + propNameBase.Substring(1);
|
|
|
|
|
|
|
|
SerializedProperty referenceProp = property.FindPropertyRelative(propNameBase + "Ref");
|
|
|
|
SerializedProperty valueProp = property.FindPropertyRelative(propNameBase + "Val");
|
|
|
|
|
|
|
|
if (referenceProp == null || valueProp == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Command command = property.serializedObject.targetObject as Command;
|
|
|
|
if (command == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var flowchart = command.GetFlowchart() as Flowchart;
|
|
|
|
if (flowchart == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var origLabel = new GUIContent(label);
|
|
|
|
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
if (EditorGUI.GetPropertyHeight(valueProp, label) <= EditorGUIUtility.singleLineHeight)
|
|
|
|
{
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
DrawSingleLineProperty(position, origLabel, referenceProp, valueProp, flowchart, typeInfo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
DrawMultiLineProperty(position, origLabel, referenceProp, valueProp, flowchart, typeInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.EndProperty();
|
|
|
|
}
|
|
|
|
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
protected virtual void DrawSingleLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,
|
|
|
|
VariableInfoAttribute typeInfo)
|
|
|
|
{
|
|
|
|
const int popupWidth = 17;
|
|
|
|
|
|
|
|
Rect controlRect = EditorGUI.PrefixLabel(rect, label);
|
|
|
|
Rect valueRect = controlRect;
|
|
|
|
valueRect.width = controlRect.width - popupWidth - 5;
|
|
|
|
Rect popupRect = controlRect;
|
|
|
|
|
|
|
|
if (referenceProp.objectReferenceValue == null)
|
|
|
|
{
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
DrawValueProperty(valueRect, valueProp, typeInfo);
|
|
|
|
popupRect.x += valueRect.width + 5;
|
|
|
|
popupRect.width = popupWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
|
|
|
|
}
|
|
|
|
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
protected virtual void DrawMultiLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart,
|
|
|
|
VariableInfoAttribute typeInfo)
|
|
|
|
{
|
|
|
|
const int popupWidth = 100;
|
|
|
|
|
|
|
|
Rect controlRect = rect;
|
|
|
|
Rect valueRect = controlRect;
|
|
|
|
valueRect.width = controlRect.width - 5;
|
|
|
|
Rect popupRect = controlRect;
|
|
|
|
|
|
|
|
if (referenceProp.objectReferenceValue == null)
|
|
|
|
{
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
DrawValueProperty(valueRect, valueProp, typeInfo);
|
|
|
|
popupRect.x = rect.width - popupWidth + 5;
|
|
|
|
popupRect.width = popupWidth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
popupRect = EditorGUI.PrefixLabel(rect, label);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
|
|
|
|
}
|
|
|
|
|
Collection (#787)
Add concept of Collection to Fungus.
Add Collection Demo, Physics Cast Demo.
They are their own type, that are addressed in a generic way. Internally using object boxing and type comparisons.
A number of refactorings and additions along with this to make it work more seamlessly.
Variable operators defined by Variable itself
Conditional and Looping commands refactored, to avoid more duplication in the new looping commands, such as ForEach
AnyVariableData removes duplication from SetVariable and Condition logic, provides a clearer method of adding additional variable types that result in immediate support in those commands
PlayMode Tests and Utils added
Additional Variable Types, such as Quaternion, Matrix4x4
Physics casts Commands that use collections
* Initial Fungus Collection work with support for int and IntegerVariable
* While and Condition related changes to allow for new command Loop Range
* Collection Get changes and ForEach rough
* Added Collection Commands
Reordered Elif logic in Condition
* More collection types and commands
* Variable reorg to allow for new types to be added more simply and centrally
* Added more Fungus Vars for Common Unity types
VariableList Adapter can delegate to the variable itself for custom drawing
Variable IsArthithemticSupported queries for each op rather than all, more fine grain support for types like color and quaterion
Event handlers, such as physics related, now have optional fungus variable to store the data they are given by unity in fungus variable for use in the block
VariableInfo consolidates more info into the typeActionLookup table, updates to support new fungus var types
* Many basic collection operations added
Common Collection types
Physics Overlap command
* Custom variable drawing moved to VariableInfo.cs rather than child variable itself
Added Physics cast and overlap commands
* Move all Editor scripts into Editor AsmDef folder
* LoopRange also registers as command name For
* Condition base class commenting improved and refactored repeated looping style child class elements into base
* More descriptive CollectionBase Command class names
* Fungus Collection interface and comments refined
* Rename ICollection to IFungusCollection
Cleanup formatting
* Collection example scene
* Added Collection Tests
* Format collection and test files
Added CopyFrom to IFungusCollection
* Added FungusCollection initial summaries
* Added CollectionRandom commands
-added simple use to CollectionLoop demo scene
* Added Unique to FungusCollection
-Updated tests to include unique
Added Collection Physics demo, shows use of returned array of all cast intersecting GameObjects
* CollectionPhysics tracks mousepos with visual
Added Fungus Command to get mouse position
* Variable custom draw moved to its own editor class, no longer part of typeinfo
Variable generation run
* Add playmode test for variable type sets
Add playmode test for flow control
* Update doco and formatting for Collection classes
Refactor parts of Conditional classes and AnyVariable
Move Property commands into Category 'Property'
* Update Collection comments, formatting and Update internal to public
* Add License header to added variable types
5 years ago
|
|
|
protected virtual void DrawValueProperty(Rect valueRect, SerializedProperty valueProp, VariableInfoAttribute typeInfo)
|
|
|
|
{
|
|
|
|
CustomVariableDrawerLookup.DrawCustomOrPropertyField(typeof(T), valueRect, valueProp);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
|
|
|
{
|
|
|
|
VariableInfoAttribute typeInfo = VariableEditor.GetVariableInfo(typeof(T));
|
|
|
|
if (typeInfo == null)
|
|
|
|
{
|
|
|
|
return EditorGUIUtility.singleLineHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
string propNameBase = typeInfo.VariableType;
|
|
|
|
propNameBase = Char.ToLowerInvariant(propNameBase[0]) + propNameBase.Substring(1);
|
|
|
|
|
|
|
|
SerializedProperty referenceProp = property.FindPropertyRelative(propNameBase + "Ref");
|
|
|
|
|
|
|
|
if (referenceProp.objectReferenceValue != null)
|
|
|
|
{
|
|
|
|
return EditorGUIUtility.singleLineHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
SerializedProperty valueProp = property.FindPropertyRelative(propNameBase + "Val");
|
|
|
|
return EditorGUI.GetPropertyHeight(valueProp, label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer (typeof(BooleanData))]
|
|
|
|
public class BooleanDataDrawer : VariableDataDrawer<BooleanVariable>
|
|
|
|
{}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer (typeof(IntegerData))]
|
|
|
|
public class IntegerDataDrawer : VariableDataDrawer<IntegerVariable>
|
|
|
|
{}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer (typeof(FloatData))]
|
|
|
|
public class FloatDataDrawer : VariableDataDrawer<FloatVariable>
|
|
|
|
{}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer (typeof(StringData))]
|
|
|
|
public class StringDataDrawer : VariableDataDrawer<StringVariable>
|
|
|
|
{}
|
|
|
|
|
|
|
|
[CustomPropertyDrawer (typeof(StringDataMulti))]
|
|
|
|
public class StringDataMultiDrawer : VariableDataDrawer<StringVariable>
|
|
|
|
{}
|
|
|
|
}
|