private void AssertObjectValue(IRegistry registry)
        {
            var componentType = registry.FindById <UTinyType>(m_ComponentType.Id);
            var entity        = registry.FindById <UTinyEntity>(m_Entity.Id);
            var component     = entity.GetComponent((UTinyType.Reference)componentType);

            Assert.AreEqual(m_Texture2D, component["TestTexture2DField"]);
        }
Beispiel #2
0
        private void HandleRedoOperation()
        {
            BindingsHelper.RemoveAllBindingsOnLoadedEntities();
            int version = int.MaxValue;

            try
            {
                do
                {
                    if (m_RedoableChanges.Count > 0)
                    {
                        //Debug.Log("Redo operation");
                        var changes = m_RedoableChanges.Last();
                        foreach (var change in changes)
                        {
                            var originator = m_Registry.FindById <IRegistryObject>(change.Id) as IOriginator;
                            version = change.Version;
                            if (null == originator)
                            {
                                originator = change.RegistryObject as IOriginator;
                            }

                            // We have no next version, which means that the originator must have been created.
                            // Knowing this, we shall remove it from the registry.
                            if (null == change.NextVersion)
                            {
                                m_Registry.Unregister(originator as IRegistryObject);
                            }
                            // Otherwise, restore the next version.
                            else
                            {
                                originator.Restore(change.NextVersion);
                            }
                        }
                        m_RedoableChanges.RemoveAt(m_RedoableChanges.Count - 1);
                        m_UndoableChanges.Add(changes);
                    }
                    else
                    {
                        break;
                    }
                }while (version < m_Undo.Version);
            }
            finally
            {
                RefreshAll();
                OnRedoPerformed?.Invoke();
                m_Caretaker.OnObjectChanged -= HandleUndoableChange;
                m_Caretaker.Update();
                m_Registry.ClearUnregisteredObjects();
                m_Caretaker.OnObjectChanged += HandleUndoableChange;
                BindingsHelper.RunAllBindingsOnLoadedEntities();
            }
        }
Beispiel #3
0
        private void AssertListValue(IRegistry registry)
        {
            var componentType = registry.FindById <UTinyType>(m_IntArrayComponentType.Id);
            var entity        = registry.FindById <UTinyEntity>(m_IntArrayEntity.Id);
            var component     = entity.GetComponent((UTinyType.Reference)componentType);
            var list          = component["TestIntArrayField"] as UTinyList;

            Assert.IsNotNull(list);
            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(3, list[0]);
            Assert.AreEqual(6, list[1]);
            Assert.AreEqual(9, list[2]);
        }
Beispiel #4
0
        private void AssertDefaultValue(IRegistry registry)
        {
            var componentType = registry.FindById <UTinyType>(m_ComponentType.Id);

            var entity    = registry.FindById <UTinyEntity>(m_Entity.Id);
            var component = entity.GetComponent((UTinyType.Reference)componentType);

            var enumReference = (UTinyEnum.Reference)component["TestEnumField"];

            // The default value has not been explicitly defined.
            // It should be set the the first field
            Assert.AreEqual(m_EnumType.Fields[0].Id, enumReference.Id);
            Assert.AreEqual(1, enumReference.Value);
        }
Beispiel #5
0
        private void AssertOverrideValue(IRegistry registry)
        {
            var componentType = registry.FindById <UTinyType>(m_ComponentType.Id);

            var entity    = registry.FindById <UTinyEntity>(m_Entity.Id);
            var component = entity.GetComponent((UTinyType.Reference)componentType);

            component.Refresh();

            var enumReference = (UTinyEnum.Reference)component["TestEnumField"];

            // The default value has not been overriden
            // It should be set the the last field
            Assert.AreEqual(m_EnumType.Fields[2].Id, enumReference.Id);
            Assert.AreEqual(3, enumReference.Value);
        }
        public static UTinyType.Reference GetTextRendererType(this IRegistry registry)
        {
            // @HACK until the module is moved to the runtime
            var type = registry.FindById <UTinyType>(new UTinyId("de741c68b67240148cdb8aa42a46bfdf"));

            if (null == type)
            {
                return(UTinyType.Reference.None);
            }
            return((UTinyType.Reference)type);
        }
        public static UTinyType.Reference GetFontType(this IRegistry registry)
        {
            // @HACK until the module is moved to the runtime
            var type = registry.FindById <UTinyType>(new UTinyId("e79a7d9b043443d8a6b5207058702290"));

            if (null == type)
            {
                return(UTinyType.Reference.None);
            }
            return((UTinyType.Reference)type);
        }
        /// <summary>
        /// Helper method to make assertions based on the {FORMAT}SerializationDefaultValues tests
        /// </summary>
        /// <param name="registry"></param>
        private void AssertSerializationDefaultValues(IRegistry registry)
        {
            // Make sure the component type is transfered with its default values
            var componentType = registry.FindById <UTinyType>(m_ComponentType.Id);
            {
                // Ensure we are dealing with the new type
                Assert.AreNotEqual(m_ComponentType, componentType);

                var defaultValue = componentType.DefaultValue as UTinyObject;

                Assert.IsNotNull(defaultValue);
                Assert.AreEqual(KTestFieldDefaultValue, defaultValue["TestIntField"]);
            }

            var defaultEntity = registry.FindById <UTinyEntity>(m_DefaultEntity.Id);
            {
                // Ensure we are dealing with the transfered entity
                Assert.AreNotEqual(m_DefaultEntity, defaultEntity);

                var c = defaultEntity.GetComponent((UTinyType.Reference)componentType);

                // TestIntField should be defaulted to 7 and marked flagged as unchanged
                Assert.IsFalse(c.IsOverridden);
                Assert.AreEqual(KTestFieldDefaultValue, c["TestIntField"]);
            }

            var overrideEntity = registry.FindById <UTinyEntity>(m_OverridenEntity.Id);
            {
                // Ensure we are dealing with the transfered entity
                Assert.AreNotEqual(m_OverridenEntity, overrideEntity);

                var c = overrideEntity.GetComponent((UTinyType.Reference)componentType);

                // TestIntField should be overriden to 10 and marked flagged as changed
                Assert.IsTrue(c.IsOverridden);
                Assert.AreEqual(KTestFieldOverrideValue, c["TestIntField"]);
            }
        }
        private static UTinyType.Reference GetType(this IRegistry registry, string name)
        {
            if (null == registry)
            {
                return(UTinyType.Reference.None);
            }
            UTinyId id;

            if (!s_IDCache.TryGetValue(name, out id))
            {
                s_IDCache[name] = id = UTinyId.Generate(name);
            }
            var type = registry.FindById <UTinyType>(id);

            if (null == type)
            {
                return(UTinyType.Reference.None);
            }
            return((UTinyType.Reference)type);
        }