diff --git a/Assets/QuickSheet/GDataPlugin/Templates/AssetFileClass.txt b/Assets/QuickSheet/GDataPlugin/Templates/AssetFileClass.txt index 8bcb8ab..c2eba01 100644 --- a/Assets/QuickSheet/GDataPlugin/Templates/AssetFileClass.txt +++ b/Assets/QuickSheet/GDataPlugin/Templates/AssetFileClass.txt @@ -1,6 +1,7 @@ using UnityEngine; using UnityEditor; using System.IO; +using UnityQuicksheet; /// /// !!! Machine generated code !!! diff --git a/Assets/QuickSheet/GDataPlugin/Templates/DataClass.txt b/Assets/QuickSheet/GDataPlugin/Templates/DataClass.txt index 7d64a8e..92e4af4 100644 --- a/Assets/QuickSheet/GDataPlugin/Templates/DataClass.txt +++ b/Assets/QuickSheet/GDataPlugin/Templates/DataClass.txt @@ -1,5 +1,6 @@ using UnityEngine; using System.Collections; +using UnityQuicksheet; /// /// !!! Machine generated code !!! diff --git a/Assets/QuickSheet/GDataPlugin/Templates/Property.txt b/Assets/QuickSheet/GDataPlugin/Templates/Property.txt index fafdedb..283ae8c 100644 --- a/Assets/QuickSheet/GDataPlugin/Templates/Property.txt +++ b/Assets/QuickSheet/GDataPlugin/Templates/Property.txt @@ -1,5 +1,6 @@ [SerializeField] string $FieldName; + using UnityQuicksheet; [ExposeProperty] public string $CapitalFieldName { get {return $FieldName; } set { $FieldName = value;} } diff --git a/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectClass.txt b/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectClass.txt index 7a116e1..9f7be12 100644 --- a/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectClass.txt +++ b/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectClass.txt @@ -2,6 +2,7 @@ using UnityEngine; using System; using System.Collections; using System.Collections.Generic; +using UnityQuicksheet; /// /// !!! Machine generated code !!! diff --git a/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectEditorClass.txt b/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectEditorClass.txt index 4977424..0c45ccf 100644 --- a/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectEditorClass.txt +++ b/Assets/QuickSheet/GDataPlugin/Templates/ScriptableObjectEditorClass.txt @@ -7,6 +7,8 @@ using System.Text; using GDataDB; using GDataDB.Linq; +using UnityQuicksheet; + /// /// !!! Machine generated code !!! /// diff --git a/Assets/QuickSheet/Util/Cloner.cs b/Assets/QuickSheet/Util/Cloner.cs index ae94170..708620b 100644 --- a/Assets/QuickSheet/Util/Cloner.cs +++ b/Assets/QuickSheet/Util/Cloner.cs @@ -2,64 +2,68 @@ using System.Collections; using System.Reflection; -/// -/// Cloner which do deep copy of an array or class instance. -/// -/// See Also: -/// http://www.codeproject.com/Articles/38270/Deep-copy-of-objects-in-C -/// -/// CAUTION: -/// For an inheritance case, deep copying all member fields of the ancestor are not tested. -/// -public class Cloner +namespace UnityQuicksheet { - public static T DeepCopy(T obj) - { - if(obj==null) - throw new ArgumentNullException("Object cannot be null"); - return (T)Process(obj); - } - static object Process(object obj) + /// + /// Cloner which do deep copy of an array or class instance. + /// + /// See Also: + /// http://www.codeproject.com/Articles/38270/Deep-copy-of-objects-in-C + /// + /// CAUTION: + /// For an inheritance case, deep copying all member fields of the ancestor are not tested. + /// + public class Cloner { - if(obj==null) - return null; - Type type=obj.GetType(); - if(type.IsValueType || type==typeof(string)) + public static T DeepCopy(T obj) { - return obj; + if (obj == null) + throw new ArgumentNullException("Object cannot be null"); + return (T)Process(obj); } - else if(type.IsArray) + + static object Process(object obj) { - Type elementType=Type.GetType( - type.FullName.Replace("[]",string.Empty)); - - var array=obj as Array; - Array copied=Array.CreateInstance(elementType,array.Length); - for(int i=0; i -{ - private TextReader _reader; - - public StreamTokenizer(TextReader reader) + public class Token { - _reader = reader; + public Token(TokenType type, string value) + { + Value = value; + Type = type; + } + + public String Value { get; private set; } + public TokenType Type { get; private set; } } - public IEnumerator GetEnumerator() + public class StreamTokenizer : IEnumerable { - String line; - StringBuilder value = new StringBuilder(); + private TextReader _reader; - while ((line = _reader.ReadLine()) != null) + public StreamTokenizer(TextReader reader) { - foreach (Char c in line) + _reader = reader; + } + + public IEnumerator GetEnumerator() + { + String line; + StringBuilder value = new StringBuilder(); + + while ((line = _reader.ReadLine()) != null) { - switch (c) + foreach (Char c in line) { - case '\'': - case '"': - if (value.Length > 0) - { - yield return new Token(TokenType.Value, value.ToString()); - value.Length = 0; - } - yield return new Token(TokenType.Quote, c.ToString()); - break; - case ',': - if (value.Length > 0) - { - yield return new Token(TokenType.Value, value.ToString()); - value.Length = 0; - } - yield return new Token(TokenType.Comma, c.ToString()); - break; - default: - value.Append(c); - break; + switch (c) + { + case '\'': + case '"': + if (value.Length > 0) + { + yield return new Token(TokenType.Value, value.ToString()); + value.Length = 0; + } + yield return new Token(TokenType.Quote, c.ToString()); + break; + case ',': + if (value.Length > 0) + { + yield return new Token(TokenType.Value, value.ToString()); + value.Length = 0; + } + yield return new Token(TokenType.Comma, c.ToString()); + break; + default: + value.Append(c); + break; + } } } } - } - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } } -} -public class CsvParser : IEnumerable -{ - private StreamTokenizer _tokenizer; - - public CsvParser(Stream data) + public class CsvParser : IEnumerable { - _tokenizer = new StreamTokenizer(new StreamReader(data)); - } + private StreamTokenizer _tokenizer; - public CsvParser(String data) - { - _tokenizer = new StreamTokenizer(new StringReader(data)); - } + public CsvParser(Stream data) + { + _tokenizer = new StreamTokenizer(new StreamReader(data)); + } - public IEnumerator GetEnumerator() - { - Boolean inQuote = false; - StringBuilder result = new StringBuilder(); + public CsvParser(String data) + { + _tokenizer = new StreamTokenizer(new StringReader(data)); + } - foreach (Token token in _tokenizer) + public IEnumerator GetEnumerator() { - switch (token.Type) + Boolean inQuote = false; + StringBuilder result = new StringBuilder(); + + foreach (Token token in _tokenizer) { - case TokenType.Comma: - if (inQuote) - { + switch (token.Type) + { + case TokenType.Comma: + if (inQuote) + { + result.Append(token.Value); + } + else + { + yield return result.ToString(); + result.Length = 0; + } + break; + case TokenType.Quote: + // Toggle quote state + inQuote = !inQuote; + break; + case TokenType.Value: result.Append(token.Value); - } - else - { - yield return result.ToString(); - result.Length = 0; - } - break; - case TokenType.Quote: - // Toggle quote state - inQuote = !inQuote; - break; - case TokenType.Value: - result.Append(token.Value); - break; - default: - throw new InvalidOperationException("Unknown token type: " + token.Type); + break; + default: + throw new InvalidOperationException("Unknown token type: " + token.Type); + } + } + + if (result.Length > 0) + { + yield return result.ToString(); } } - if (result.Length > 0) + IEnumerator IEnumerable.GetEnumerator() { - yield return result.ToString(); + return GetEnumerator(); } } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } } \ No newline at end of file diff --git a/Assets/QuickSheet/Util/Singleton.cs b/Assets/QuickSheet/Util/Singleton.cs index ddd847b..41d20d8 100644 --- a/Assets/QuickSheet/Util/Singleton.cs +++ b/Assets/QuickSheet/Util/Singleton.cs @@ -1,33 +1,36 @@ using UnityEngine; -/// -/// Singleton base class. -/// Derive this class to make it Singleton. -/// -public class Singleton : MonoBehaviour where T : MonoBehaviour +namespace UnityQuicksheet { - protected static T instance; - /// - /// Returns the instance of this singleton. + /// Singleton base class. + /// Derive this class to make it Singleton. /// - public static T Instance + public class Singleton : MonoBehaviour where T : MonoBehaviour { - get + protected static T instance; + + /// + /// Returns the instance of this singleton. + /// + public static T Instance { - if(instance == null) + get { - instance = (T) FindObjectOfType(typeof(T)); - if (instance == null) { - GameObject obj = new GameObject(typeof(T).ToString()); - instance = obj.AddComponent(); - //Debug.LogError("An instance of " + typeof(T) + - // " is needed in the scene, but there is none."); + instance = (T)FindObjectOfType(typeof(T)); + + if (instance == null) + { + GameObject obj = new GameObject(typeof(T).ToString()); + instance = obj.AddComponent(); + //Debug.LogError("An instance of " + typeof(T) + + // " is needed in the scene, but there is none."); + } } + return instance; } - return instance; - } - } + } + } } \ No newline at end of file