P4Connect.AssetPostProcessor.cs #1

  • //
  • guest/
  • anis_sg/
  • perforce_software/
  • p4connect/
  • src/
  • P4Connect/
  • P4Connect/
  • P4Connect.AssetPostProcessor.cs
  • View
  • Commits
  • Open Download .zip Download (2 KB)
using UnityEditor;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace P4Connect
{
	/// <summary>
	/// This class hooks onto the Asset Save/Delete/Move process and makes sure that
	/// Perforce is updated accordingly. It uses the perforce connection class
	/// (which internally uses Config to retrieve the connection settings)
	/// to open a connection to the server and add the required changes (add/checkout/delete/move).
	/// </summary>
	public class AssetPostProcessor
		: UnityEditor.AssetPostprocessor
	{
        private static readonly ILog log = LogManager.GetLogger(typeof(AssetPostProcessor));

		public static void OnPostprocessAllAssets (
			String [] aImportedAssets,
			String [] aDeletedAssets,
			String [] aMovedAssets,
			String [] aMovedFromAssetPaths)
		{
            if (!Config.ValidConfiguration)         // Should I queue up this stuff until the configuration is valid?
                return;

#if DEBUG
            log.DebugFormat("import: {0} delete: {1} move: {2} moveTo: {3}",
                Logger.StringArrayToString(aImportedAssets), 
                Logger.StringArrayToString(aDeletedAssets),
                Logger.StringArrayToString(aMovedAssets), 
                Logger.StringArrayToString(aMovedFromAssetPaths));
#endif
			if (aImportedAssets.Length > 0)
			{  
				Engine.CreateAssets(aImportedAssets);
			}
			if (aDeletedAssets.Length > 0)
			{
				Engine.DeleteAssets(aDeletedAssets);
			}
			if (aMovedAssets.Length > 0)
			{
				Engine.MoveAssets(aMovedFromAssetPaths, aMovedAssets);
			}
#if DEBUG
            log.Debug("... Complete");
#endif
		}
	}
}
# Change User Description Committed
#1 12954 anis_sg Populate -o //guest/perforce_software/p4connect/...
//guest/anis_sg/perforce_software/p4connect/....
//guest/perforce_software/p4connect/src/P4Connect/P4Connect/P4Connect.AssetPostProcessor.cs
#4 12553 Norman Morse integrate from internal main
Build fixes for EC.
Major changes to Configuration and re-initialization code.
Bug fixes
#3 12512 Norman Morse Integrate from Dev branch, preparing for Beta3 release
#2 12362 Norman Morse Added Debug Logging for p4log
Fixed some path comparison issues.
Created a CaseSensitivity test
#1 10940 Norman Morse Inital Workshop release of P4Connect.
Released under BSD-2 license