public static string GetJsTypeName(UTinyModule module, UTinyRegistryObjectBase @object)
        {
            var name = @object.Name;

            if (!string.IsNullOrEmpty(module?.Namespace))
            {
                name = module.Namespace + "." + name;
            }

            var type = @object as UTinyType;

            if (type != null)
            {
                switch (type.TypeCode)
                {
                case UTinyTypeCode.Unknown:
                    break;

                case UTinyTypeCode.Int8:
                case UTinyTypeCode.Int16:
                case UTinyTypeCode.Int32:
                case UTinyTypeCode.Int64:
                case UTinyTypeCode.UInt8:
                case UTinyTypeCode.UInt16:
                case UTinyTypeCode.UInt32:
                case UTinyTypeCode.UInt64:
                case UTinyTypeCode.Float32:
                case UTinyTypeCode.Float64:
                case UTinyTypeCode.Boolean:
                case UTinyTypeCode.Char:
                case UTinyTypeCode.String:
                    return(name.ToLower());

                case UTinyTypeCode.EntityReference:
                    // @TODO remove the magic value
                    return("ut.Entity");

                case UTinyTypeCode.Configuration:
                case UTinyTypeCode.Component:
                case UTinyTypeCode.Struct:
                case UTinyTypeCode.Enum:
                case UTinyTypeCode.UnityObject:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(name);
        }
        private static void HandleRenameEnded(UTinyRegistryObjectBase obj)
        {
            var textAsset = (TextAsset)null;

            if (obj is UTinySystem)
            {
                textAsset = ((UTinySystem)obj)?.TextAsset;
            }
            else if (obj is UTinyScript)
            {
                textAsset = ((UTinyScript)obj)?.TextAsset;
            }

            var oldPath = AssetDatabase.GetAssetPath(textAsset);

            AssetDatabase.RenameAsset(oldPath, $"{obj.Name}.js.txt");
        }
        public static IEnumerable <UTinyModule> GetModules(UTinyRegistryObjectBase @object)
        {
            if (@object is UTinyType)
            {
                return(GetModules(@object.Registry, (UTinyType.Reference)(UTinyType) @object));
            }

            if (@object is UTinyEntityGroup)
            {
                return(GetModules(@object.Registry, (UTinyEntityGroup.Reference)(UTinyEntityGroup) @object));
            }

            if (@object is UTinySystem)
            {
                return(GetModules(@object.Registry, (UTinySystem.Reference)(UTinySystem) @object));
            }

            if (@object is UTinyScript)
            {
                return(GetModules(@object.Registry, (UTinyScript.Reference)(UTinyScript) @object));
            }

            return(Enumerable.Empty <UTinyModule>());
        }
 public static string GetJsTypeName(UTinyRegistryObjectBase @object)
 {
     Assert.IsNotNull(@object);
     return(GetJsTypeName(UTinyUtility.GetModules(@object).FirstOrDefault(), @object));
 }
 public void Restore(UTinyRegistryObjectBase obj)
 {
     Data.Position = 0;
     FrontEnd.Accept(Data, obj.Registry);
 }
 public CommandMemento(UTinyRegistryObjectBase obj)
 {
     Version = obj.Version;
     Data    = new MemoryStream();
     BackEnd.Persist(Data, obj);
 }