static string GetInitChunkAsString(LuaBehaviour lb)
        {
            var bytes = lb.GetInitChunk();

            if (bytes == null || bytes.Length == 0)
            {
                return(string.Empty);
            }
            return(System.Text.Encoding.UTF8.GetString(bytes));
        }
        void SetInitChunkByString(LuaBehaviour lb, string chunk)
        {
            var prop = serializedObject.FindProperty("_InitChunk");

            if (prop != null)
            {
                if (string.IsNullOrEmpty(chunk))
                {
                    prop.ClearArray();
                    lb.SetInitChunk(null);
                }
                else
                {
                    var bytes = System.Text.Encoding.UTF8.GetBytes(chunk);
                    prop.arraySize = bytes.Length;
                    for (int i = 0; i < bytes.Length; ++i)
                    {
                        prop.GetArrayElementAtIndex(i).intValue = (int)bytes[i];
                    }
                    lb.SetInitChunk(bytes);
                }
                serializedObject.ApplyModifiedProperties();
            }
        }
Beispiel #3
0
 internal void SetLuaBehaviour(LuaBehaviour behaviour)
 {
     luaBehaviour = behaviour;
 }
Beispiel #4
0
 public void Load()
 {
     Debug.Assert(luaVm == null);
     luaVm = new Lua();
     LuaBehaviour.SetLua(luaVm);
 }