Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System.IO;
- using System.Xml;
- public class ContentManager : MonoBehaviour
- {
- public static ContentManager Instance;
- public bool ignoreVideos;
- private ProjectData[] projects;
- private int projectsLength;
- [HideInInspector]
- public string currentLoadingState;
- [HideInInspector]
- public string currentLoadingItem;
- [HideInInspector]
- private int texturesTotal;
- [HideInInspector]
- private int texturesLoaded;
- private string previousContent;
- private string currentContent;
- private string applicationPath;
- public delegate void OnDoneLoading ();
- public event OnDoneLoading OnDoneLoadingEvent = delegate { };
- public delegate void OnLoadError (bool _critical, string _message);
- public event OnLoadError OnLoadErrorEvent = delegate { };
- private string localContentFolderPrefix;
- private string SharedContentFolder;
- private bool checkByteLength;
- private bool checkDateModified;
- private bool mailLoadingReport;
- private void Awake ()
- {
- Instance = this;
- applicationPath = GetApplicationPath();
- }
- private void Start ()
- {
- StartCoroutine( "Load" );
- }
- private bool copySucces;
- private IEnumerator Load ()
- {
- currentLoadingState = "";
- currentLoadingItem = "";
- yield return null;
- //load settings
- localContentFolderPrefix = Settings.localContentFolderPrefix; //Config.Instance.GetValue<string>( "SharedContentFolder" ); <localContentFolderPrefix>Temp_</localContentFolderPrefix>
- SharedContentFolder = Settings.SharedContentFolder; //Config.Instance.GetValue<string>( "localContentFolderPrefix" ); <SharedContentFolder>D:\Temp\FORUM_CONTENT_TEST</SharedContentFolder>
- checkByteLength = Settings.checkByteLength; //Config.Instance.GetValue<bool>( "checkByteLength" ); <checkByteLength>True</checkByteLength>
- checkDateModified = Settings.checkDateModified; //Config.Instance.GetValue<bool>( "checkDateModified" ); <checkDateModified>True</checkDateModified>
- mailLoadingReport = Settings.mailLoadingReport; //Config.Instance.GetValue<bool>( "mailLoadingReport" ); <mailLoadingReport>True</mailLoadingReport>
- //Find previous content folders
- previousContent = "";
- currentContent = applicationPath + localContentFolderPrefix + System.DateTime.Now.ToString("yyyyMMddHH");
- yield return StartCoroutine( GetPreviousContent() );
- //If previous content is too old
- if (previousContent != currentContent)
- {
- //If couldn't find any older content
- if (string.IsNullOrEmpty( previousContent ))
- {
- //Scan directories
- currentLoadingState = "Scanning directories";
- ContentDirectory contentShared;
- try
- {
- contentShared = ScanDirectory( SharedContentFolder, "" );
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to scan directories!" );
- yield break;
- }
- yield return null;
- //Copy shared to new content folder
- currentLoadingState = "Downloading latest content";
- copySucces = true;
- StartCoroutine( CopyDirectory( contentShared, true ) );
- if (!copySucces)
- {
- OnLoadErrorEvent( false, "Unable to load new content" );
- }
- }
- //Else could find: compare content
- else
- {
- //Scan directories
- currentLoadingState = "Scanning directories";
- ContentDirectory contentShared;
- ContentDirectory contentLastest;
- try
- {
- contentShared = ScanDirectory( SharedContentFolder, "" );
- contentLastest = ScanDirectory( previousContent, "" );
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to scan directories!" );
- yield break;
- }
- yield return null;
- //Compare and copy to new content folder
- currentLoadingState = "Copying content";
- copySucces = true;
- StartCoroutine( CompareAndCopyDirectory( contentShared, contentLastest, true ) );
- if (!copySucces)
- {
- currentContent = previousContent;
- OnLoadErrorEvent( false, "Unable to compare with new content" );
- }
- }
- }
- yield return null;
- //Load XML from directories into project data list
- currentLoadingState = "Preparing to load content";
- yield return new WaitForSeconds( 1f );
- List<ProjectData> list = new List<ProjectData>();
- yield return StartCoroutine( LoadXml( list ) );
- //Save list to projects array
- projects = list.ToArray();
- projectsLength = projects.Length;
- Debug.Log("Done reading xml");
- //Load all textures from projects array
- yield return null;
- if(!ignoreVideos)
- yield return StartCoroutine( LoadContent( list ) );
- //End
- yield return null;
- OnDoneLoadingEvent();
- }
- public ProjectData GetProjectByIndex (int _index)
- {
- return projects[_index];
- }
- public int GetAmountOfProjects ()
- {
- return projectsLength;
- }
- #region DOWNLOAD_AND_BACKUP
- private IEnumerator GetPreviousContent ()
- {
- currentLoadingState = "Loading old content folders";
- int current = int.Parse( System.DateTime.Now.ToString( "yyyyMMddHH" ) );
- int latest = 0;
- string[] directories;
- try
- {
- directories = Directory.GetDirectories( applicationPath );
- }
- catch
- {
- OnLoadErrorEvent( false, "Failed to load directories." );
- yield break;
- }
- string name;
- for (int i = 0; i < directories.Length; i++)
- {
- name = GetLastFolderOrFile( directories[i] );
- if (name.Contains(localContentFolderPrefix))
- {
- int date = int.Parse( name.Substring( localContentFolderPrefix.Length ) );
- if (date > latest)
- {
- latest = date;
- }
- }
- }
- if (latest == 0)
- {
- previousContent = "";
- yield break;
- }
- previousContent = applicationPath + localContentFolderPrefix + latest;
- }
- private IEnumerator CompareAndCopyDirectory (ContentDirectory _shared, ContentDirectory _backup, bool _skipAllowed)
- {
- currentLoadingItem = "";
- if (!CreateDirectory( currentContent + "/" + _shared.local ))
- {
- OnLoadErrorEvent( false, "Unable to create new folder! " + _shared.local );
- copySucces = false;
- yield break;
- }
- for (int i = 0; i < _shared.directoriesLength; i++)
- {
- if (_backup.DoesContainDirectory( _shared.directories[i].name ))
- yield return CompareAndCopyDirectory( _shared.directories[i], _backup.GetDirectory( _shared.directories[i].name ), false );
- else
- yield return CopyDirectory( _shared.directories[i], false );
- if (!copySucces)
- if (_skipAllowed)
- copySucces = true;
- else
- yield break;
- if (_skipAllowed)
- yield return null;
- }
- for (int i = 0; i < _shared.filesLength; i++)
- {
- ContentFile file = _backup.GetFile( _shared.files[i].name );
- if (file != null && (checkByteLength ? _shared.files[i].length == file.length : true) && (checkDateModified ? _shared.files[i].unixModified == file.unixModified : true))
- File.Copy( previousContent + "/" + _backup.local + "/" + _backup.files[i].name, currentContent + "/" + _backup.local + "/" + _backup.files[i].name );
- else
- File.Copy( SharedContentFolder + "/" + _shared.local + "/" + _shared.files[i].name, currentContent + "/" + _shared.local + "/" + _shared.files[i].name );
- currentLoadingItem = currentContent + "/" + _shared.local + "/" + _shared.files[i].name;
- yield return null;
- }
- yield break;
- }
- private IEnumerator CopyDirectory (ContentDirectory _shared, bool _skipAllowed)
- {
- currentLoadingItem = "";
- if (!CreateDirectory( currentContent + "/" + _shared.local ))
- {
- OnLoadErrorEvent( false, "Unable to create new folder! " + _shared.local );
- copySucces = false;
- yield break;
- }
- for (int i = 0; i < _shared.directoriesLength; i++)
- {
- yield return CopyDirectory( _shared.directories[i], false );
- if (!copySucces)
- if (_skipAllowed)
- copySucces = true;
- else
- yield break;
- if (_skipAllowed)
- yield return null;
- }
- for (int i = 0; i < _shared.filesLength; i++)
- {
- File.Copy( SharedContentFolder + "/" + _shared.local + "/" + _shared.files[i].name, currentContent + "/" + _shared.local + "/" + _shared.files[i].name );
- currentLoadingItem = currentContent + "/" + _shared.local + "/" + _shared.files[i].name;
- yield return null;
- }
- yield break;
- }
- private bool DoesDirectoryExist (string _url, bool _createIfNot)
- {
- try
- {
- if (Directory.Exists( _url ))
- return true;
- if (!_createIfNot)
- return false;
- Directory.CreateDirectory( _url );
- return true;
- }
- catch
- {
- return false;
- }
- }
- private bool CreateDirectory (string _url)
- {
- try
- {
- Directory.CreateDirectory( _url );
- return true;
- }
- catch
- {
- Debug.Log( "Failed to create directory" );
- return false;
- }
- }
- private bool EmptyDirectory (string _url)
- {
- try
- {
- if(Directory.Exists(_url))
- Directory.Delete( _url, true );
- Directory.CreateDirectory( _url );
- return true;
- }
- catch
- {
- return false;
- }
- }
- private bool ReplaceDirectory (string _from, string _to)
- {
- try
- {
- if (Directory.Exists( _to ))
- Directory.Delete( _to, true );
- if (Directory.Exists( _from ))
- Directory.Move( _from, _to );
- return true;
- }
- catch
- {
- return false;
- }
- }
- private ContentDirectory ScanDirectory ( string _path, string _local )
- {
- List<ContentDirectory> directories = new List<ContentDirectory>();
- List<ContentFile> files = new List<ContentFile>();
- string directoryName = GetLastFolderOrFile( _path );
- string[] d = Directory.GetDirectories( _path );
- int dLength = d.Length;
- string[] f = Directory.GetFiles( _path );
- int fLength = f.Length;
- for (int i = 0; i < dLength; i++)
- directories.Add( ScanDirectory( d[i], _local + "/" + GetLastFolderOrFile(d[i]) ) );
- for (int i = 0; i < fLength; i++)
- files.Add( ScanFileInfo( f[i] ) );
- return new ContentDirectory( GetLastFolderOrFile( _path ), _path, _local, directories.ToArray(), dLength, files.ToArray(), fLength );
- }
- private ContentFile ScanFileInfo ( string _path )
- {
- FileInfo fi = new FileInfo( _path );
- return new ContentFile( GetLastFolderOrFile(_path), _path, fi.Length, fi.LastWriteTime.Ticks);
- }
- #endregion DOWNLOAD_AND_BACKUP
- #region XML_HELPERS
- private IEnumerator LoadXml (List<ProjectData> _list)
- {
- currentLoadingState = "Loading Directories";
- currentLoadingItem = "";
- string[] directories = null;
- int directoriesLength = 0;
- try
- {
- directories = Directory.GetDirectories( currentContent );
- directoriesLength = directories.Length;
- }
- catch
- {
- OnLoadErrorEvent( true, "Failed to load directory content directory" );
- yield break;
- }
- int contentLength;
- string contentFile;
- ProjectContentType type;
- currentLoadingState = "Loading Projects";
- for (int i = 0; i < directoriesLength; i++)
- {
- ProjectData project = new ProjectData();
- string xml = FindXML( directories[i] + "/" );
- currentLoadingItem = xml;
- if (!string.IsNullOrEmpty( xml ))
- {
- project.directoryName = GetLastFolderOrFile( directories[i] );
- project.xmlName = GetLastFolderOrFile( xml );
- XmlDocument doc = EncodeXml( project, xml );
- if (doc != null)
- {
- project.imageURL = TryLoadXmlValue( project, doc, ProjectXmlTag.projectImage );
- if (!string.IsNullOrEmpty( project.imageURL ))
- {
- project.imageURL = directories[i] + "/" + project.imageURL;
- texturesTotal++;
- }
- project.projectID = TryLoadXmlValue( project, doc, ProjectXmlTag.projectId );
- project.tags = TryLoadXmlValue( project, doc, ProjectXmlTag.projectTags ).SplitToArray<string>();
- project.budget = TryParseInt( project, ProjectXmlTag.projectBudget, TryLoadXmlValue( project, doc, ProjectXmlTag.projectBudget ) );
- project.year = TryParseInt( project, ProjectXmlTag.projectYear, TryLoadXmlValue( project, doc, ProjectXmlTag.projectYear ) );
- project.company = TryLoadXmlValue( project, doc, ProjectXmlTag.projectCompany );
- XmlNode textDE = TryLoadXmlNode( project, doc, ProjectXmlTag.textDE );
- if (textDE != null)
- {
- project.textDE.name = TryLoadXmlValueInNode( project, textDE, ProjectXmlTag.textName );
- project.textDE.owner = TryLoadXmlValueInNode( project, textDE, ProjectXmlTag.textOwner );
- project.textDE.title = TryLoadXmlValueInNode( project, textDE, ProjectXmlTag.textTitle );
- project.textDE.introduction = TryLoadXmlValueInNode( project, textDE, ProjectXmlTag.textIntroduction );
- project.textDE.description = TryLoadXmlValueInNode( project, textDE, ProjectXmlTag.textDescription );
- }
- else
- {
- OnLoadErrorEvent( false, "Unable to read <" + ProjectXmlTag.textDE + "> in '/" + project.directoryName + "/" + project.xmlName + "'" );
- }
- XmlNode textEN = TryLoadXmlNode( project, doc, ProjectXmlTag.textEN );
- if (textEN != null)
- {
- project.textEN.name = TryLoadXmlValueInNode( project, textEN, ProjectXmlTag.textName );
- project.textEN.owner = TryLoadXmlValueInNode( project, textEN, ProjectXmlTag.textOwner );
- project.textEN.title = TryLoadXmlValueInNode( project, textEN, ProjectXmlTag.textTitle );
- project.textEN.introduction = TryLoadXmlValueInNode( project, textEN, ProjectXmlTag.textIntroduction );
- project.textEN.description = TryLoadXmlValueInNode( project, textEN, ProjectXmlTag.textDescription );
- }
- else
- {
- OnLoadErrorEvent( false, "Unable to read <" + ProjectXmlTag.textEN + "> in '/" + project.directoryName + "/" + project.xmlName + "'" );
- }
- XmlNodeList contentDE = TryLoadXmlNodeList( project, doc, ProjectXmlTag.contentDE );
- if (contentDE != null)
- {
- List<ProjectContentBase> contentList = new List<ProjectContentBase>();
- contentLength = contentDE.Count;
- for (int c = 0; c < contentLength; c++)
- {
- contentFile = contentDE[c].InnerText;
- type = FileExtensionToContentType( contentFile );
- if (type == ProjectContentType.VIDEO)
- contentList.Add( new ProjectContentVideo( directories[i] + "/" + contentFile ) );
- else if (type == ProjectContentType.IMAGE)
- contentList.Add( new ProjectContentImage( directories[i] + "/" + contentFile ) );
- else if (string.IsNullOrEmpty( contentFile ))
- OnLoadErrorEvent( false, "<" + ProjectXmlTag.contentItem + "> in '/" + project.directoryName + "/" + project.xmlName + "' is empty!" );
- else
- OnLoadErrorEvent( false, "File format is not supported! '" + contentFile + "' in '/" + project.directoryName + "/" + project.xmlName + "'" );
- }
- project.contentDE = contentList.ToArray();
- project.contentDELength = contentList.Count;
- texturesTotal += project.contentDELength;
- }
- XmlNodeList contentEN = TryLoadXmlNodeList( project, doc, ProjectXmlTag.contentEN );
- if (contentEN != null)
- {
- List<ProjectContentBase> contentList = new List<ProjectContentBase>();
- contentLength = contentEN.Count;
- for (int c = 0; c < contentLength; c++)
- {
- contentFile = contentEN[c].InnerText;
- type = FileExtensionToContentType( contentFile );
- if (type == ProjectContentType.VIDEO)
- contentList.Add( new ProjectContentVideo( directories[i] + "/" + contentFile ) );
- else if (type == ProjectContentType.IMAGE)
- contentList.Add( new ProjectContentImage( directories[i] + "/" + contentFile ) );
- else if (string.IsNullOrEmpty( contentFile ))
- OnLoadErrorEvent( false, "<" + ProjectXmlTag.contentItem + "> in '/" + project.directoryName + "/" + project.xmlName + "' is empty!" );
- else
- OnLoadErrorEvent( false, "File format is not supported! '" + contentFile + "' in '/" + project.directoryName + "/" + project.xmlName + "'" );
- }
- project.contentEN = contentList.ToArray();
- project.contentENLength = contentList.Count;
- texturesTotal += project.contentENLength;
- }
- _list.Add( project );
- }
- }
- if (i % 10 == 0)
- yield return null;
- }
- }
- private string FindXML (string _url)
- {
- string xml = "";
- try
- {
- string[] files = Directory.GetFiles( _url );
- for (int i = files.Length - 1; i > -1; i--)
- {
- if (GetExtensionFromPath( files[i] ).Contains( "xml" ))
- {
- xml = files[i];
- break;
- }
- }
- }
- catch
- {
- OnLoadErrorEvent( false, "Folder /" + GetLastFolderOrFile( _url ) + "/ does not contain a .xml file!" );
- }
- return xml;
- }
- private XmlDocument EncodeXml (ProjectData _project, string _xmlUrl)
- {
- XmlDocument doc = new XmlDocument();
- try
- {
- doc.Load( _xmlUrl );
- return doc;
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to load '" + _project.xmlName + "' in '/" + _project.directoryName + "/'" );
- return null;
- }
- }
- private XmlNode TryLoadXmlNode (ProjectData _project, XmlDocument _doc, string _tag)
- {
- try
- {
- return _doc.GetElementsByTagName( _tag )[0];
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to read <" + _tag + "> in '/" + _project.directoryName + "/" + _project.xmlName + "'" );
- return null;
- }
- }
- private XmlNodeList TryLoadXmlNodeList (ProjectData _project, XmlDocument _doc, string _tag)
- {
- try
- {
- return _doc.GetElementsByTagName( _tag )[0].ChildNodes;
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to read <" + _tag + "> in '/" + _project.directoryName + "/" + _project.xmlName + "'" );
- return null;
- }
- }
- private string TryLoadXmlValue (ProjectData _project, XmlDocument _doc, string _tag)
- {
- try
- {
- return _doc.GetElementsByTagName( _tag )[0].InnerText;
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to read <" + _tag + "> in '/" + _project.directoryName + "/" + _project.xmlName + "'" );
- return "";
- }
- }
- private string TryLoadXmlValueInNode (ProjectData _project, XmlNode _node, string _tag)
- {
- try
- {
- return _node[_tag].InnerText;
- }
- catch
- {
- OnLoadErrorEvent( false, "Unable to read <" + _tag + "> in '/" + _project.directoryName + "/" + _project.xmlName + "'" );
- return "";
- }
- }
- private int TryParseInt (ProjectData _project, string _tag, string _string)
- {
- try
- {
- return int.Parse( _string );
- }
- catch
- {
- OnLoadErrorEvent( false, "<" + _tag + "> in '/" + _project.directoryName + "/" + _project.xmlName + "' is not a number!" );
- return 0;
- }
- }
- #endregion XML_HELPERS
- #region CONTENT_LOADING
- private IEnumerator LoadContent (List<ProjectData> _list)
- {
- currentLoadingState = "Loading Textures";
- texturesTotal = 0;
- texturesLoaded = 0;
- int length = _list.Count;
- for (int i = 0; i < length; i++)
- {
- yield return StartCoroutine( LoadProjectImage( _list[i] ) );
- yield return StartCoroutine( LoadProjectContent( _list[i], _list[i].contentDE, _list[i].contentDELength, ProjectXmlTag.contentDE ) );
- yield return StartCoroutine( LoadProjectContent( _list[i], _list[i].contentEN, _list[i].contentENLength, ProjectXmlTag.contentEN ) );
- }
- }
- private IEnumerator LoadProjectImage ( ProjectData _project )
- {
- currentLoadingItem = _project.imageURL;
- if (!string.IsNullOrEmpty( _project.imageURL ))
- {
- WWW www = new WWW( "File://" + _project.imageURL );
- yield return www;
- if (string.IsNullOrEmpty( www.error ))
- _project.image = www.texture;
- else
- OnLoadErrorEvent( false, "Failed to load <" + ProjectXmlTag.projectImage + "> in '" + _project.directoryName + "/" + _project.xmlName + "'" );
- texturesLoaded++;
- UpdateTextureLoadingProgress();
- }
- else
- {
- OnLoadErrorEvent( false, "<" + ProjectXmlTag.projectImage + "> in '" + _project.directoryName + "/" + _project.xmlName + "' is empty!" );
- }
- }
- private IEnumerator LoadProjectContent ( ProjectData _project, ProjectContentBase[] _array, int _arrayLength, string _tag )
- {
- for (int j = 0; j < _arrayLength; j++)
- {
- if (_array[j].type != ProjectContentType.IMAGE)
- continue;
- string contentItemURL = (_array[j] as ProjectContentImage).textureURL;
- currentLoadingItem = contentItemURL;
- if (!string.IsNullOrEmpty( contentItemURL ))
- {
- WWW www = new WWW( "File://" + contentItemURL );
- yield return www;
- if (string.IsNullOrEmpty( www.error ))
- (_array[j] as ProjectContentImage).texture2d = www.texture;
- else
- OnLoadErrorEvent( false, "Failed to load <" + ProjectXmlTag.contentItem + "> " + (j + 1) + " in <" + _tag + "> in '" + _project.directoryName + "/" + _project.xmlName + "'" );
- texturesLoaded++;
- UpdateTextureLoadingProgress();
- }
- else
- {
- OnLoadErrorEvent( false, "<" + ProjectXmlTag.contentItem + "> " + (j + 1) + " in <" + _tag + "> in '" + _project.directoryName + "/" + _project.xmlName + "' is empty" );
- }
- }
- }
- private ProjectContentType FileExtensionToContentType ( string _url )
- {
- switch (GetExtensionFromPath( _url ).ToLower())
- {
- case "mp4":
- return ProjectContentType.VIDEO;
- case "jpg":
- return ProjectContentType.IMAGE;
- case "jpeg":
- return ProjectContentType.IMAGE;
- case "png":
- return ProjectContentType.IMAGE;
- default:
- return ProjectContentType.NULL;
- }
- }
- private void UpdateTextureLoadingProgress ()
- {
- currentLoadingState = "Loading Textures " + Mathf.FloorToInt( (((float)texturesLoaded) / ((float)texturesTotal)) * 100f ) + "%";
- }
- #endregion CONTENT_LOADING
- #region FILE_HELPERS
- private string GetExtensionFromPath (string _path)
- {
- string[] split = _path.Split( '.' );
- return split[split.Length - 1].ToLower();
- }
- private string GetLastFolderOrFile (string _path)
- {
- _path = _path.Replace( @"\", "/" );
- string[] split = _path.Split( '/' );
- return split[split.Length - 1];
- }
- private string GetApplicationPath ()
- {
- string applicationPath = Application.dataPath;
- string[] split = applicationPath.Split( '/' );
- return applicationPath.Substring( 0, applicationPath.Length - split[split.Length - 1].Length );
- }
- #endregion FILE_HELPERS
- }
- #region DOWNLOAD_AND_BACKUP
- public class ContentDirectory
- {
- public string name;
- public string path;
- public string local;
- public ContentDirectory[] directories;
- public int directoriesLength;
- public ContentFile[] files;
- public int filesLength;
- public ContentDirectory (string _name, string _path, string _local, ContentDirectory[] _directories, int _directoriesLength , ContentFile[] _files, int _filesLength)
- {
- name = _name;
- path = _path;
- local = _local;
- directories = _directories;
- directoriesLength = _directoriesLength;
- files = _files;
- filesLength = _filesLength;
- }
- public bool DoesContainDirectory (string _directoryName)
- {
- for (int i = 0; i < directoriesLength; i++)
- if (directories[i].name == _directoryName)
- return true;
- return false;
- }
- public ContentDirectory GetDirectory (string _directoryName)
- {
- for (int i = 0; i < directoriesLength; i++)
- if (directories[i].name == _directoryName)
- return directories[i];
- return null;
- }
- public bool DoesContainFile (string _fileName)
- {
- for (int i = 0; i < filesLength; i++)
- if (files[i].name == _fileName)
- return true;
- return false;
- }
- public ContentFile GetFile (string _fileName)
- {
- for (int i = 0; i < filesLength; i++)
- if (files[i].name == _fileName)
- return files[i];
- return null;
- }
- }
- public class ContentFile
- {
- public string name;
- public string path;
- public long length;
- public long unixModified;
- public ContentFile (string _name, string _path, long _length, long _unixModified)
- {
- name = _name;
- path = _path;
- length = _length;
- unixModified = _unixModified;
- }
- }
- #endregion DOWNLOAD_AND_BACKUP
- #region DATA
- public class ProjectXmlTag
- {
- public static string projectId = "projectID";
- public static string projectImage = "projectImage";
- public static string projectTags = "projectTags";
- public static string projectBudget = "projectBudget";
- public static string projectYear = "projectYear";
- public static string projectCompany = "projectCompany";
- public static string textDE = "texts_DE";
- public static string textEN = "texts_EN";
- public static string textName = "name";
- public static string textOwner = "owner";
- public static string textTitle = "title";
- public static string textIntroduction = "introduction";
- public static string textDescription = "description";
- public static string contentDE = "content_DE";
- public static string contentEN = "content_EN";
- public static string contentItem = "item";
- }
- public class ProjectData
- {
- public string projectID = "";
- public string directoryName = "";
- public string xmlName = "";
- public Texture2D image = null;
- public string imageURL = "";
- public string[] tags = new string[]{};
- public int budget = 0;
- public int year = 0;
- public string company = "";
- public ProjectText textDE = new ProjectText();
- public ProjectText textEN = new ProjectText();
- public ProjectContentBase[] contentDE = new ProjectContentBase[]{};
- public int contentDELength = 0;
- public ProjectContentBase[] contentEN = new ProjectContentBase[]{};
- public int contentENLength = 0;
- }
- public class ProjectText
- {
- public string name = "";
- public string owner = "";
- public string title = "";
- public string introduction = "";
- public string description = "";
- }
- public class ProjectContentBase
- {
- public ProjectContentType type = ProjectContentType.NULL;
- }
- public class ProjectContentImage : ProjectContentBase
- {
- public ProjectContentImage (string _url)
- {
- textureURL = _url;
- type = ProjectContentType.IMAGE;
- }
- public Texture2D texture2d = null;
- public string textureURL = "";
- }
- public class ProjectContentVideo : ProjectContentBase
- {
- public ProjectContentVideo (string _url)
- {
- videoURL = _url;
- type = ProjectContentType.VIDEO;
- }
- public string videoURL = "";
- }
- public enum ProjectContentType
- {
- NULL,
- IMAGE,
- VIDEO
- }
- #endregion DATA
Add Comment
Please, Sign In to add comment