public CommandLineOperation CreateSVNAction(string action, bool asynchronous, IEnumerable <string> assets)
 {
     return(CreateSVNAction(action, asynchronous, assets, (source, e) =>
     {
         if (asynchronous)
         {
             var syncOp = new SyncedToUpdateOperation(() =>
             {
                 if (e.output.failed)
                 {
                     SendSVNErrorEvent(e.output);
                 }
                 OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(e.output, new SVNStatusDatabase(svnStatusDatabase)));
             });
             syncOp.Queue();
         }
         else
         {
             if (e.output.failed)
             {
                 SendSVNErrorEvent(e.output);
             }
             OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(e.output, new SVNStatusDatabase(svnStatusDatabase)));
         }
     }));
 }
        private void HandleSVNStatusUpdate(CommandLineOutput output, bool async)
        {
            var xmlResult = new XmlDocument();

            xmlResult.LoadXml(output.outputStr);
            ParseStatusResult(xmlResult);
            if (async)
            {
                var syncOp = new SyncedToUpdateOperation(() =>
                {
                    if (output.failed)
                    {
                        SendSVNErrorEvent(output);
                    }
                    AssetDatabase.Refresh();
                    OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(output, new SVNStatusDatabase(svnStatusDatabase)));
                });
                syncOp.Queue();
            }
            else
            {
                if (output.failed)
                {
                    SendSVNErrorEvent(output);
                }
                var syncOp = new SyncedToUpdateOperation(AssetDatabase.Refresh);
                syncOp.Queue();
                OnDatabaseHandlerEvent(new SVNDatabaseUpdatedArgs(output, new SVNStatusDatabase(svnStatusDatabase)));
            }
        }
Beispiel #3
0
    private static void RevertPrefab(GameObject gameObject)
    {
        var syncedOp = new SyncedToUpdateOperation(() =>
        {
            EditorUtility.ReconnectToLastPrefab(gameObject);
            var prefabRoot   = EditorUtility.FindPrefabRoot(gameObject);
            var prefabParent = EditorUtility.GetPrefabParent(prefabRoot) as GameObject;

            var replacedPrefab = EditorUtility.InstantiatePrefab(prefabParent) as GameObject;

            replacedPrefab.transform.position   = prefabRoot.transform.position;
            replacedPrefab.transform.rotation   = prefabRoot.transform.rotation;
            replacedPrefab.transform.localScale = prefabRoot.transform.localScale;
            replacedPrefab.transform.parent     = prefabRoot.transform.parent;

            Object.DestroyImmediate(prefabRoot);

            Selection.activeGameObject = replacedPrefab;
            EditorUtility.UnloadUnusedAssets();
        });

        syncedOp.Queue();

        // Revert the prefab and Unity reloads it in the scene
        if (ShouldSVNRevert(gameObject))
        {
            SVNRevert(gameObject);
        }
    }
Beispiel #4
0
    public static void DisconnectPrefab(GameObject gameObject)
    {
        // instantiate prefab at prefab location, remove original prefab instance.
        var syncedOp = new SyncedToUpdateOperation(() =>
        {
            Undo.RegisterSceneUndo("Disconnect Prefab");
            var prefabRoot    = EditorUtility.FindPrefabRoot(gameObject);
            var prefabParent  = EditorUtility.GetPrefabParent(prefabRoot) as GameObject;
            string prefabName = prefabParent.name;

            var replacedPrefab = Object.Instantiate(prefabParent, prefabRoot.transform.position, prefabRoot.transform.rotation) as GameObject;
            replacedPrefab.transform.localScale = prefabRoot.transform.localScale;
            replacedPrefab.name             = prefabName;
            replacedPrefab.transform.parent = prefabRoot.transform.parent;

            Object.DestroyImmediate(prefabRoot);

            Selection.activeGameObject = replacedPrefab;
            EditorUtility.UnloadUnusedAssets();
        });

        syncedOp.Queue();
        Selection.activeGameObject = null;
    }