public void SetUp() { m_Registry = new UTinyRegistry(); m_EnumType = m_Registry.CreateType( UTinyId.New(), "TestEnum", UTinyTypeCode.Enum); m_EnumType.BaseType = (UTinyType.Reference)UTinyType.Int32; m_EnumType.CreateField("A", (UTinyType.Reference)UTinyType.Int32); m_EnumType.CreateField("B", (UTinyType.Reference)UTinyType.Int32); m_EnumType.CreateField("C", (UTinyType.Reference)UTinyType.Int32); m_EnumType.DefaultValue = new UTinyObject(m_Registry, (UTinyType.Reference)m_EnumType) { // @NOTE We are intentionally starting at 1 to detect 0 case as errors ["A"] = 1, ["B"] = 2, ["C"] = 3 }; // Create a component with a single int field m_ComponentType = m_Registry.CreateType( UTinyId.New(), "TestComponent", UTinyTypeCode.Component); m_ComponentType.CreateField( "TestEnumField", (UTinyType.Reference)m_EnumType); m_Entity = m_Registry.CreateEntity(UTinyId.New(), "TestEntity"); var component = m_Entity.AddComponent((UTinyType.Reference)m_ComponentType); component.Refresh(); }
public void SetUp() { m_Registry = new UTinyRegistry(); // Create a component with a single int field m_ComponentType = m_Registry.CreateType( UTinyId.New(), "TestComponent", UTinyTypeCode.Component); m_ComponentType.CreateField( "TestIntField", (UTinyType.Reference)UTinyType.Int32); // Default the TestStruct.IntField to 7 m_ComponentType.DefaultValue = new UTinyObject(m_Registry, (UTinyType.Reference)m_ComponentType) { ["TestIntField"] = KTestFieldDefaultValue }; // Create an entity with our test component m_DefaultEntity = m_Registry.CreateEntity(UTinyId.New(), "DefaultEntity"); { var c = m_DefaultEntity.AddComponent((UTinyType.Reference)m_ComponentType); c.Refresh(); } // Create another entity with our test component m_OverridenEntity = m_Registry.CreateEntity(UTinyId.New(), "OverridenEntity"); { var c = m_OverridenEntity.AddComponent((UTinyType.Reference)m_ComponentType); c.Refresh(); c["TestIntField"] = KTestFieldOverrideValue; } }
public void SetUp() { m_Registry = new UTinyRegistry(); // Create a component with a single Texture2D field m_ComponentType = m_Registry.CreateType( UTinyId.New(), "TestComponent", UTinyTypeCode.Component); m_ComponentType.CreateField( "TestTexture2DField", (UTinyType.Reference)UTinyType.Texture2DEntity); m_Entity = m_Registry.CreateEntity(UTinyId.New(), "TestEntity"); var component = m_Entity.AddComponent((UTinyType.Reference)m_ComponentType); component.Refresh(); // Create some asset on disc File.WriteAllBytes(Application.dataPath + "/TestTexture.png", new Texture2D(32, 32).EncodeToPNG()); AssetDatabase.ImportAsset("Assets/TestTexture.png"); m_Texture2D = AssetDatabase.LoadAssetAtPath <Texture2D>("Assets/TestTexture.png"); }
public void SetUp() { m_Registry = new UTinyRegistry(); // Create a component with an int array field m_IntArrayComponentType = m_Registry.CreateType( UTinyId.New(), "TestComponent", UTinyTypeCode.Component); m_IntArrayComponentType.CreateField( "TestIntArrayField", (UTinyType.Reference)UTinyType.Int32, true); m_IntArrayEntity = m_Registry.CreateEntity(UTinyId.New(), "TestEntity"); var component = m_IntArrayEntity.AddComponent((UTinyType.Reference)m_IntArrayComponentType); component.Refresh(); component["TestIntArrayField"] = new UTinyList(m_Registry, (UTinyType.Reference)UTinyType.Int32) { 3, 6, 9 }; m_StructType = m_Registry.CreateType( UTinyId.New(), "TestStruct", UTinyTypeCode.Struct); m_StructType.CreateField( "TestIntField", (UTinyType.Reference)UTinyType.Int32); m_StructArrayComponentType = m_Registry.CreateType( UTinyId.New(), "TestComponent2", UTinyTypeCode.Component); m_StructArrayComponentType.CreateField( "TestStructArrayField", (UTinyType.Reference)m_StructType, true); m_StructArrayEntity = m_Registry.CreateEntity(UTinyId.New(), "TestEntity2"); var component2 = m_StructArrayEntity.AddComponent((UTinyType.Reference)m_StructArrayComponentType); component2.Refresh(); component2["TestStructArrayField"] = new UTinyList(m_Registry, (UTinyType.Reference)m_StructType) { new UTinyObject(m_Registry, (UTinyType.Reference)m_StructType) { ["TestIntField"] = 3 }, new UTinyObject(m_Registry, (UTinyType.Reference)m_StructType) { ["TestIntField"] = 6 }, new UTinyObject(m_Registry, (UTinyType.Reference)m_StructType) { ["TestIntField"] = 9 } }; }