Inheritance: IManageableObject, IDisposable, ICloneExplicit
		private int ResolveMappingConflict(Resource input, ExportInputAssignment[] conflictingAssignments)
		{
			// Ask the input Resource which importer it would prefer
			if (input != null && input.AssetInfo != null && input.AssetInfo.ImporterId != null)
			{
				for (int i = 0; i < conflictingAssignments.Length; i++)
				{
					// If we have a match with the preferred importer, this is definitely the correct assignment to handle this.
					if (conflictingAssignments[i].Importer.Id == input.AssetInfo.ImporterId)
						return i;
				}
			}

			// By default, fall back on simply prefering the highest-priority importer
			int keepIndex = -1;
			int highestPrio = int.MinValue;
			for (int i = 0; i < conflictingAssignments.Length; i++)
			{
				if (conflictingAssignments[i].Importer.Priority > highestPrio)
				{
					highestPrio = conflictingAssignments[i].Importer.Priority;
					keepIndex = i;
				}
			}

			// If there is a conflict handler (such as "spawn a user dialog"), see if that can deal with it.
			if (this.conflictHandler != null)
			{
				ConflictData data = new ConflictData(input, conflictingAssignments, keepIndex);
				IAssetImporter selectedImporter = this.conflictHandler(data);
				int selectedIndex = conflictingAssignments.IndexOfFirst(item => item.Importer == selectedImporter);
				return selectedIndex;
			}

			return keepIndex;
		}
Example #2
0
		public void Resolve(Resource result)
		{
			if (result == null) throw new ArgumentNullException("result");
			if (result.Disposed) throw new ObjectDisposedException("result");
			this.result = result;
		}
		public AssetExportEnvironment(string exportDir, Resource input)
		{
			this.exportDir = exportDir;
			this.input = input;
		}
		public bool IsUsingSrcFile(Resource r, string srcFile)
		{
			Pixmap p = r as Pixmap;
			return p != null && p.SourcePath == srcFile;
		}
		public void ReimportFile(Resource r, string srcFile)
		{
			Pixmap p = r as Pixmap;
			p.LoadPixelData(srcFile);
		}
        private bool TryGetValue(Resource res, string key, out object value)
        {
            value = null;

            if (res == null) return false;
            if (res.AssetInfo == null) return false;
            if (res.AssetInfo.CustomData == null) return false;

            Dictionary<string,object> data = res.AssetInfo.CustomData;
            return data.TryGetValue(this.targetKey, out value);
        }
		public void ReimportFile(Resource r, string srcFile)
		{
			AudioData a = r as AudioData;
			a.LoadOggVorbisData(srcFile);
		}
		public void ReimportFile(Resource r, string srcFile)
		{
			AbstractShader s = r as AbstractShader;
			s.LoadSource(srcFile);
			s.Compile();
		}
		public static void OpenSourceFile(Resource r, string srcFileExt, Action<string> saveSrcToAction)
		{
			// Default content: Use temporary location
			if (r.Path.Contains(':'))
			{
				string tmpLoc = Path.Combine(Path.GetTempPath(), r.Path.Replace(':', '_')) + srcFileExt;
				saveSrcToAction(tmpLoc);
				System.Diagnostics.Process.Start(tmpLoc);
			}
			// Other content: Use permanent src file location
			else
			{
				string srcFilePath = r.SourcePath;
				if (String.IsNullOrEmpty(srcFilePath) || !File.Exists(srcFilePath))
				{
					srcFilePath = GenerateSourceFilePath(r, srcFileExt);
					Directory.CreateDirectory(Path.GetDirectoryName(srcFilePath));
					r.SourcePath = srcFilePath;
				}

				if (srcFilePath != null)
				{
					saveSrcToAction(srcFilePath);
					System.Diagnostics.Process.Start(srcFilePath);
				}
			}
		}
Example #10
0
 /// <summary>
 /// Deep-copies this Resource to the specified target Resource. The target Resource's Type must
 /// match this Resource's Type.
 /// </summary>
 /// <param name="target">The target Resource to copy this Resource's data to</param>
 public void CopyTo(Resource target)
 {
     this.DeepCopyTo(target);
 }
		public bool IsUsingSrcFile(Resource r, string srcFile)
		{
			AbstractShader s = r as AbstractShader;
			return s != null && s.SourcePath == srcFile;
		}
		public void ReimportFile(Resource r, string srcFile)
		{
			Font f = r as Font;
			f.LoadCustomFamilyData(srcFile);
			f.ReloadData();
		}
		public bool IsUsingSrcFile(Resource r, string srcFile)
		{
			Font f = r as Font;
			return f != null && f.CustomFamilyData != null && f.SourcePath == srcFile;
		}
Example #14
0
		/// <summary>
		/// Registers a <see cref="Resource"/> and maps it to the specified path key.
		/// </summary>
		/// <param name="path">The path key to map the Resource to</param>
		/// <param name="content">The Resource to register.</param>
		public static void AddContent(string path, Resource content)
		{
			if (String.IsNullOrEmpty(path)) return;
			if (String.IsNullOrEmpty(content.Path)) content.Path = path;
			resLibrary[path] = content;
		}
Example #15
0
			public ConflictData(Resource input, ExportInputAssignment[] conflicts, int defaultIndex)
			{
				this.input = input;
				this.conflicts = conflicts;
				this.defaultIndex = defaultIndex;
			}
		public static string GenerateSourceFilePath(Resource r, string srcFileExt)
		{
			string filePath = PathHelper.MakeFilePathRelative(r.Path, DualityApp.DataDirectory);
			string fileDir = Path.GetDirectoryName(filePath);
			if (filePath.Contains(".."))
			{
				filePath = Path.GetFileName(filePath);
				fileDir = ".";
			}
			return PathHelper.GetFreePath(Path.Combine(Path.Combine(EditorHelper.SourceMediaDirectory, fileDir), r.Name), srcFileExt);
		}
Example #17
0
		public AssetExportOperation(Resource input, string exportDir)
		{
			this.exportDir = exportDir;
			this.input = input;
		}
Example #18
0
		private static string[] GetSourceMediaPaths(Resource resource)
		{
			if (resource == null) return new string[0];
			return AssetManager.SimulateExportAssets(resource);
		}
        private bool TrySetValue(Resource res, string key, object value)
        {
            if (res == null) return false;
            if (res.AssetInfo == null) return false;
            if (res.AssetInfo.CustomData == null) return false;

            Dictionary<string,object> data = res.AssetInfo.CustomData;
            if (!data.ContainsKey(this.targetKey)) return false;

            data[this.targetKey] = value;
            return true;
        }
		public bool IsUsingSrcFile(Resource r, string srcFile)
		{
			AudioData a = r as AudioData;
			return a != null && a.SourcePath == srcFile;
		}