Example #1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            TestSerializeBehaviour myTarget = (TestSerializeBehaviour)target;

            if (GUILayout.Button("TestSerialize"))
            {
                Undo.RecordObject(myTarget, "TestSerialize");
                myTarget.CreateNewData();
                SerializeDebugHelper.VerifyCorrectSerialization(myTarget, SerializeDebugHelper.LogToFileMode.AlwaysLog);
            }

            if (GUILayout.Button("TestSerialize (Bulk)"))
            {
                Undo.RecordObject(myTarget, "TestSerializeBulk");
                for (int i = 0; i < 10; ++i)
                {
                    myTarget.CreateNewData();
                    SerializeDebugHelper.VerifyCorrectSerialization(myTarget);
                }
            }

            if (GUILayout.Button("Dump File"))
            {
                myTarget.TrySaveAndGetReadableBlob(true);
            }
        }
Example #2
0
        public string TrySaveAndGetReadableBlob(bool dumpToFile)
        {
            try
            {
                Serializer serializer = new Serializer();
                serializer.BeginSaving();
                AdditionalSerialize(serializer);
                byte[] serializedBlob = serializer.EndSaving();

                string debugStr = Serializer.ToDebugString(serializedBlob);

                if (dumpToFile)
                {
                    SerializeDebugHelper.WriteToParserDebugFile(debugStr);
                }

                return(debugStr);
            }
            catch (System.Exception e)
            {
                Debug.Assert(false, "Serialization Failed :(\n" + e.ToString());
            }

            return("");
        }
        ///////////////////////////////////////////////////////////////////////////
        public override string ToString()
        {
            string outDebugString = "";

            outDebugString += SerializeDebugHelper.AddToSerializationDebugString(m_CompoundClass);

            return outDebugString;
        }
        ///////////////////////////////////////////////////////////////////////////
        public override string ToString()
        {
            string debugString = "";

            // ints
            for (int i = 0; i < m_TestInts.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestInts[i]);
            }

            // floats
            for (int i = 0; i < m_TestFloats.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestFloats[i]);
            }

            // double
            for (int i = 0; i < m_TestDoubles.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestDoubles[i]);
            }

            // string
            for (int i = 0; i < m_TestStrings.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_String(m_TestStrings[i]);
            }

            // bool
            for (int i = 0; i < m_TestBools.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestBools[i]);
            }

            // char
            for (int i = 0; i < m_TestChars.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestChars[i]);
            }

            // enum
            for (int i = 0; i < m_TestEnums.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString_Builtin(m_TestEnums[i]);
            }

            ///////////////////////////////////////////////////////////////////////////

            // simple serializables
            for (int i = 0; i < m_SimpleSerializables.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString(m_SimpleSerializables[i]);
            }

            // Sub 1
            for (int i = 0; i < m_PolySub1s.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString(m_PolySub1s[i]);
            }

            // Sub 2
            for (int i = 0; i < m_PolySub2s.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString(m_PolySub2s[i]);
            }

            // Mixed
            for (int i = 0; i < m_PolyBases.Length; ++i)
            {
                debugString += SerializeDebugHelper.AddToSerializationDebugString(m_PolyBases[i]);
            }

            ///////////////////////////////////////////////////////////////////////////

            // Lists
            debugString += SerializeDebugHelper.AddToSerializationDebugString_BuiltinList(m_ListIntNull);
            debugString += SerializeDebugHelper.AddToSerializationDebugString_BuiltinList(m_ListInt);
            debugString += SerializeDebugHelper.AddToSerializationDebugString_List(m_ListSimpleSerializablesNull);
            debugString += SerializeDebugHelper.AddToSerializationDebugString_List(m_ListSimpleSerializables);
            debugString += SerializeDebugHelper.AddToSerializationDebugString_List(m_ListPolyBase);
            debugString += SerializeDebugHelper.AddToSerializationDebugString_List(m_ListPolySub);

            return debugString;
        }