Browse Source

Single file for registering types in text file

master
chrisgregan 9 years ago
parent
commit
e60488bc5b
  1. 2
      Assets/Fungus/FungusScript/Resources/Types/ExtensionTypes.txt
  2. 70
      Assets/Fungus/FungusScript/Resources/Types/RegisterTypes.txt
  3. 18
      Assets/Fungus/FungusScript/Scripts/Editor/FungusScriptEditor.cs
  4. 21
      Assets/Fungus/FungusScript/Scripts/Editor/LuaBindingsEditor.cs

2
Assets/Fungus/FungusScript/Resources/Types/ExtensionTypes.txt

@ -1,2 +1,2 @@
Fungus.FungusScriptExtensions, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null


70
Assets/Fungus/FungusScript/Resources/Types/RegisterTypes.txt

@ -1,32 +1,40 @@
Fungus.AnimatorVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.AudioSourceVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Block, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.BooleanVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Character, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.ColorVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Command, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.CommandInfoAttribute, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.FacingDirection, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.FloatVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Flowchart, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.FungusPrefs, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.FungusScript, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.GameObjectVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.IntegerVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Label, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.MaterialVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.MenuDialog, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.ObjectVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.PortraitState, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.SayDialog, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.SpriteVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.StringVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Task, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.TextureVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.TransformVariable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Variable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Vector2Variable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Fungus.Vector3Variable, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
# List of c# types to register with MoonSharp
# LuaBindings usually takes care of registering the types of bound objects, but in some
# cases you'll need to register a type manually by adding it to this list.
# You can also register types using MoonSharp's UserData class in the Awake method of a component.
# To register an extension type, add the E: prefix
# If the type is defined in the main assembly then you can just use namespace.typename
# If the type is defined in any other assembly you need to use the full assembly qualified type name.
Fungus.AnimatorVariable
Fungus.AudioSourceVariable
Fungus.Block
Fungus.BooleanVariable
Fungus.Character
Fungus.ColorVariable
Fungus.Command
Fungus.CommandInfoAttribute
Fungus.FacingDirection
Fungus.FloatVariable
Fungus.Flowchart
Fungus.FungusPrefs
Fungus.FungusScript
Fungus.GameObjectVariable
Fungus.IntegerVariable
Fungus.Label
Fungus.MaterialVariable
Fungus.MenuDialog
Fungus.ObjectVariable
Fungus.PortraitState
Fungus.SayDialog
Fungus.SpriteVariable
Fungus.StringVariable
Fungus.Task
Fungus.TextureVariable
Fungus.TransformVariable
Fungus.Variable
Fungus.Vector2Variable
Fungus.Vector3Variable
System.Action, System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.IEnumerator, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
@ -84,3 +92,7 @@ UnityEngine.Vector2, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyTok
UnityEngine.Vector3, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
UnityEngine.Vector4, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
UnityEngine.VerticalWrapMode, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
# Extension types
E:Fungus.FungusScriptExtensions

18
Assets/Fungus/FungusScript/Scripts/Editor/FungusScriptEditor.cs

@ -16,9 +16,6 @@ namespace Fungus
protected SerializedProperty registerTypesProp;
protected ReorderableList registerTypeList;
protected SerializedProperty registerExtensionTypesProp;
protected ReorderableList registerExtensionTypesList;
protected virtual void OnEnable()
{
registerTypesProp = serializedObject.FindProperty("registerTypes");
@ -33,20 +30,6 @@ namespace Fungus
SerializedProperty element = registerTypesProp.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(r, element, new GUIContent(""));
};
registerExtensionTypesProp = serializedObject.FindProperty("registerExtensionTypes");
registerExtensionTypesList = new ReorderableList(serializedObject, registerExtensionTypesProp, true, true, true, true);
registerExtensionTypesList.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Register Extension Types");
};
registerExtensionTypesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
Rect r = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
SerializedProperty element = registerExtensionTypesProp.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(r, element, new GUIContent(""));
};
}
public override void OnInspectorGUI()
@ -56,7 +39,6 @@ namespace Fungus
serializedObject.Update();
registerTypeList.DoLayoutList();
registerExtensionTypesList.DoLayoutList();
serializedObject.ApplyModifiedProperties();
}

21
Assets/Fungus/FungusScript/Scripts/Editor/LuaBindingsEditor.cs

@ -148,6 +148,12 @@ namespace Fungus
ShowBindingMemberInfo();
// Update the bound types on every tick to make sure they're up to date.
// This could be a bit heavy on performance if the bound object list is long, but
// I couldn't get it to work reliably by only updating when the list has changed.
// This only happens when inspecting a Fungus Bindings component so I think it'll be ok.
PopulateBoundTypes();
serializedObject.ApplyModifiedProperties();
}
@ -339,7 +345,7 @@ namespace Fungus
/// <summary>
/// Update the list of bound types on the LuaBindings object.
/// </summary>
protected virtual void PopulateUserDataTypes()
protected virtual void PopulateBoundTypes()
{
LuaBindings luaBindings = target as LuaBindings;
@ -361,12 +367,17 @@ namespace Fungus
}
}
string s = "";
// Store the final list of types in the luaBindings object
SerializedProperty boundTypesProp = serializedObject.FindProperty("boundTypes");
boundTypesProp.ClearArray();
int index = 0;
foreach (System.Type t in typeSet)
{
s += t.AssemblyQualifiedName + "\n";
boundTypesProp.InsertArrayElementAtIndex(index);
SerializedProperty element = boundTypesProp.GetArrayElementAtIndex(index);
element.stringValue = t.AssemblyQualifiedName;
index++;
}
Debug.Log(s);
}
/// <summary>
@ -432,7 +443,7 @@ namespace Fungus
AddSubType(typeSet, containedType);
}
}
else
else if (t != typeof(System.Object))
{
// Non-IEnumerable/IEnumerator types will be registered.
typeSet.Add(t);

Loading…
Cancel
Save