public override IEnumerator Execute(UTContext context)
    {
        if (startOfSubtree == null)
        {
            Debug.LogError("No subtree specified.");
            yield break;
        }

        Dictionary <string, bool> SDK_Channel = context["SDK_Channel"] as Dictionary <string, bool>;

        Debug.Log("For Each: Items == " + SDK_Channel);

        var i = 0;

        if (SDK_Channel is IEnumerable)
        {
            foreach (string channelID in (IEnumerable)SDK_Channel.Keys)
            {
                i++;
                Debug.Log("For Each: i == " + i + "  channelID==" + channelID);
                Debug.Log("For Each: is Build " + channelID + "?? " + SDK_Channel[channelID]);
                if (SDK_Channel[channelID])
                {
                    context["channelID_forBuild"] = channelID;
                    Debug.Log("ExecutePath next step");
                    var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
                    do
                    {
                        yield return("");
                    }while (enumerator.MoveNext());
                }
            }
        }
    }
Example #2
0
    /// <summary>
    /// Returns an estimation of the plan's run time from the history of previous runtimes.
    /// </summary>
    /// <returns>
    /// The expected runtime. If the plan never run before 0 is returned.
    /// </returns>
    /// <param name='plan'>
    /// The plan.
    /// </param>
    public static bool GetExpectedRuntime(UTAutomationPlan plan, out float time)
    {
        var i     = 0;
        var found = false;

        do
        {
            var entry = EditorPrefs.GetString(PlanPrefix + i, "");
            if (string.IsNullOrEmpty(entry))
            {
                break;
            }
            if (entry == plan.Guid)
            {
                found = true;
                break;
            }
            i++;
        } while (true);
        if (found)
        {
            time = EditorPrefs.GetFloat(PlanPrefix + i + ".time", 0f);
        }
        else
        {
            time = 0;
        }
        return(found);
    }
Example #3
0
    /// <summary>
    /// Runs the specified plan.
    /// </summary>
    public static void Run(UTAutomationPlan plan, Dictionary <string, string> additionalProperties)
    {
        if (UTPreferences.ClearConsoleBeforeStart)
        {
            UTils.ClearConsole();
        }
        var context = new UTContext();

        if (additionalProperties != null)
        {
            foreach (var entry in additionalProperties)
            {
                string name = entry.Key;
                string val  = entry.Value;
                if (UTPreferences.DebugMode)
                {
                    Debug.Log("Setting additional property: " + name + " = " + val);
                }
                context[name] = val;
            }
        }

        UTMainWindow.Init();
        var runner = UTomateRunner.Instance;

        runner.RequestRun(plan, context);
    }
 public static void EditAutomationPlan(UTAutomationPlan plan)
 {
     UTAutomationPlanWindow window = EditorWindow.GetWindow<UTAutomationPlanWindow> ();
     window.title = "Plan Editor";
     window.plan = plan;
     window.RefreshInternals();
 }
    public static void CreateEcosystemPlan()
    {
        // get the folder selection

        // create a new plan at the currently selected folder.
        UTAutomationPlan plan = UTils.CreateAssetOfType <UTAutomationPlan>("name");

        // create a new instance of the new class we created above.
        var editorModel = new PlayMakerEcosystem_uTomateModel();

        editorModel.LoadPlan(plan);

        Selection.activeInstanceID = plan.GetInstanceID();

        // now you can create actions.

        // FIRST ACTION
        UTEchoAction echoAction = UTAction.Create <UTEchoAction>();

        // set their properties
        echoAction.text.Value         = "Hello World";
        echoAction.text.UseExpression = false; // this toggles f(x)

        // add the action to the automation plan
        var echoActionEntry = editorModel.AddAction(echoAction);

        echoActionEntry.name = "wtf";

        Selection.activeInstanceID = plan.GetInstanceID();

        // SECOND ACTION
        UTEchoAction anotherAction = UTAction.Create <UTEchoAction>();


        // set their properties
        anotherAction.text.Value         = "double dva";
        anotherAction.text.UseExpression = false; // this toggles f(x)

        // add it as well
        var anotherActionEntry = editorModel.AddAction(anotherAction);


        //CONNECT
        // now connect the first echo action to the other action using the Connect method we wrote
        editorModel.Connect(echoActionEntry, anotherActionEntry);

        // finally set the echo action as first action
        var echoActionNode = editorModel.Graph.GetNodeFor(echoActionEntry);

        editorModel.SetFirstNode(echoActionNode);


        // if you want you can beautify the graph
        // so not all nodes are located at (0,0)
        editorModel.RelayoutPlan();

        // finally you can execute your plan using
        UTomate.Run(plan);
    }
Example #6
0
    public static void EditAutomationPlan(UTAutomationPlan plan)
    {
        UTAutomationPlanWindow window = EditorWindow.GetWindow <UTAutomationPlanWindow> ();

        window.title = "Plan Editor";
        window.plan  = plan;
        window.RefreshInternals();
    }
 private static void PlanRunHack(UTAutomationPlan plan)
 {
     // this is a hack around Unity Cloud Build not supporting coroutine semantics.
     // will be removed once coroutine semantics are there.
     var enumerator = RunPlan(plan);
     while (enumerator.MoveNext())
     {
         // loop until done.
     }
 }
Example #8
0
        private static void PlanRunHack(UTAutomationPlan plan)
        {
            // this is a hack around Unity Cloud Build not supporting coroutine semantics.
            // will be removed once coroutine semantics are there.
            var enumerator = RunPlan(plan);

            while (enumerator.MoveNext())
            {
                // loop until done.
            }
        }
Example #9
0
    public override IEnumerator Execute(UTContext context)
    {
        /*if (startOfSubtree == null) {
         *      Debug.LogWarning("No subtree specified.");
         *      yield break;
         * }
         *
         * var theItemsPropertyName = itemsPropertyName.EvaluateIn(context);
         *
         * var items = context[theItemsPropertyName];
         *
         * var theItemPropertyName = itemPropertyName.EvaluateIn(context);
         *
         * if ( items is IEnumerable ) {
         *      foreach(var item in (IEnumerable)items) {
         *              context[theItemPropertyName] = item;
         *              var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
         *              Debug.Log("222");
         *              do {
         *                      yield return "";
         *              }
         *              while (enumerator.MoveNext());
         *      }
         * }*/
        Dictionary <string, bool> SDK_Channel = new Dictionary <string, bool> ();

        SDK_Channel = context["Dictionary"] as Dictionary <string, bool>;

        foreach (var item in SDK_Channel.Keys)
        {
            Debug.Log("foreach :" + item.ToString());

            string ss = SDK_Channel[item].ToString();
            if (ss.Equals("True"))
            {
                var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
                Debug.Log("foreach true:" + ss);
                do
                {
                    yield return("");
                }while (enumerator.MoveNext());
            }
        }

        /*Debug.Log("000"+SDK_Channel["Android_91"]);
         * //UTBool  android91 = context ["Android_91"] as UTBool;
         * string s = context ["Android_91"].ToString();
         * Debug.Log("111"+s);
         * if(s.Equals("True")){
         *      Debug.Log("222");
         * }
         * yield return "";*/
    }
Example #10
0
 public void HandleContextMenu(int index)
 {
     if (index != -1)
     {
         var planList          = showHidden ? plans : visiblePlans;
         UTAutomationPlan plan = planList [index];
         GenericMenu      menu = new GenericMenu();
         menu.AddItem(new GUIContent("Run"), false, ExecutePlan, plan);
         menu.AddItem(new GUIContent("Edit"), false, EditPlan, plan);
         menu.AddItem(new GUIContent("Locate"), false, LocatePlan, plan);
         menu.ShowAsContext();
     }
 }
    public override IEnumerator Execute(UTContext context)
    {
        if (startOfSubtree == null)
        {
            Debug.LogWarning("No subtree specified.");
            yield break;
        }

        var theItemsPropertyName = itemsPropertyName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theItemsPropertyName))
        {
            throw new UTFailBuildException("You need to specify the name of the property which holds the list of items.", this);
        }

        var items = context[theItemsPropertyName];

        var theItemPropertyName = itemPropertyName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theItemsPropertyName))
        {
            throw new UTFailBuildException("You need to specify the name of the property which holds the current item.", this);
        }

        var theIndexPropertyName = indexPropertyName.EvaluateIn(context);
        var indexPropertySet     = !string.IsNullOrEmpty(theIndexPropertyName);

        var index = 0;

        if (items is IEnumerable)
        {
            foreach (var item in (IEnumerable)items)
            {
                context[theItemPropertyName] = item;
                if (indexPropertySet)
                {
                    context[theIndexPropertyName] = index;
                }
                var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
                do
                {
                    yield return("");
                }while (enumerator.MoveNext());
                index++;
            }
        }
    }
Example #12
0
    public override IEnumerator Execute(UTContext context)
    {
        if (startOfSubtree == null)
        {
            Debug.LogWarning("No subtree specified.");
            yield break;
        }

        UTFileUtils.FileSelectionMode theMode = UTFileUtils.FileSelectionMode.Files;
        if (selectionMode != null)           // can happen when we migrate older automation plans which didn't have this setting.
        {
            theMode = selectionMode.EvaluateIn(context);
        }

        var theFilePropertyName = filePropertyName.EvaluateIn(context);

        if (string.IsNullOrEmpty(theFilePropertyName))
        {
            throw new UTFailBuildException("You need to specify the property which holds the current file.", this);
        }

        var theIncludes = UTAction.EvaluateAll(includes, context);
        var theExcludes = UTAction.EvaluateAll(excludes, context);

        var files = UTFileUtils.CalculateFileset(theIncludes, theExcludes, theMode);

        var theIndexPropertyName = indexPropertyName.EvaluateIn(context);
        var indexPropertySet     = !string.IsNullOrEmpty(theIndexPropertyName);

        var index = 0;

        foreach (var file in files)
        {
            context [theFilePropertyName] = file;
            if (indexPropertySet)
            {
                context [theIndexPropertyName] = index;
            }
            var enumerator = UTAutomationPlan.ExecutePath(startOfSubtree, context);
            do
            {
                yield return("");
            } while (enumerator.MoveNext());
            index++;
        }
    }
        private static IEnumerator RunPlan(UTAutomationPlan plan)
        {
            UTPreferences.DebugMode = UTUnityCloudBuildConfiguration.UnityCloudBuildConfiguration.debugMode;

            Debug.LogWarning("About to run the plan: " + plan.name);
            var start = Time.realtimeSinceStartup;

            global::UTomate.Run(plan);

            var took = Time.realtimeSinceStartup - start;
            while (UTomateRunner.Instance.IsRunning)
            {
                UTomateRunner.Instance.ContinueRunning();
                yield return null;
            }

            Debug.LogWarning("Plan ran. Took " + took + "ms");
        }
Example #14
0
        private static IEnumerator RunPlan(UTAutomationPlan plan)
        {
            UTPreferences.DebugMode = UTUnityCloudBuildConfiguration.UnityCloudBuildConfiguration.debugMode;

            Debug.LogWarning("About to run the plan: " + plan.name);
            var start = Time.realtimeSinceStartup;

            global::UTomate.Run(plan);

            var took = Time.realtimeSinceStartup - start;

            while (UTomateRunner.Instance.IsRunning)
            {
                UTomateRunner.Instance.ContinueRunning();
                yield return(null);
            }

            Debug.LogWarning("Plan ran. Took " + took + "ms");
        }
Example #15
0
    /// <summary>
    /// Requests to run a certain plan. Only one plan can run at a time.
    /// </summary>
    /// <param name='plan'>
    /// The plan to run.
    /// </param>
    /// <param name='context'>
    /// Context in which the plan should run.
    /// </param>
    public void RequestRun(UTAutomationPlan plan, UTContext context)
    {
#if UTOMATE_DEMO
        // when developing utomate demo locally we want to allow our own plans, so we set another flag which
        // removes this restriction for us.
#if !UTOMATE_DEVELOPMENT_MODE
        if (UTomate.CheckPlanCountExceeded())
        {
            return;
        }
#endif
#endif

        if (IsRunning)
        {
            throw new InvalidOperationException("The runner is currently busy. Use IsRunning to check if the runner is busy, before invoking this.");
        }
        this.plan    = plan;
        this.context = context;
        float expectedTimeInSeconds = 0;
        this.planWasRunBefore     = UTStatistics.GetExpectedRuntime(plan, out expectedTimeInSeconds);
        this.expectedTime         = TimeSpan.FromSeconds(expectedTimeInSeconds);
        UTPreferences.LastRunPlan = plan.name;
        planLookupDone            = false;

        if (OnRunnerStarted != null)
        {
            OnRunnerStarted();
        }
        // save all changes to assets before run.
        AssetDatabase.SaveAssets();
        EditorApplication.SaveAssets();

        // keep stuff running in background
        // this will overwrite playersettings implicitely, therefore we store the previous value here..
        playerSettingsRunInBackgroundValue = PlayerSettings.runInBackground;
        Application.runInBackground        = true;
        // and set it back here... so we don't f**k up the settings that were set before running utomate.
        PlayerSettings.runInBackground = playerSettingsRunInBackgroundValue;
        this.reloadOfAssembliesLocked  = false;
    }
	/// <summary>
	/// Runs the specified plan.
	/// </summary>
	public static void Run (UTAutomationPlan plan, Dictionary<string,string> additionalProperties)
	{
		if (UTPreferences.ClearConsoleBeforeStart) {
			UTils.ClearConsole();
		}
		var context = new UTContext();
		if (additionalProperties != null) {
			foreach(var entry in additionalProperties) {
				string name = entry.Key;
				string val = entry.Value;
				if (UTPreferences.DebugMode) {
					Debug.Log("Setting additional property: " + name + " = " + val);
				}
				context[name] = val;
			}
		}
		
		UTMainWindow.Init();
		var runner = UTomateRunner.Instance;
		runner.RequestRun(plan, context);
	}
Example #17
0
    /// <summary>
    /// Records the runtime of an automation plan which allows making an estimation on the run time when the plan
    /// runs next time.
    /// </summary>
    /// <param name='plan'>
    /// The plan
    /// </param>
    /// <param name='seconds'>
    /// The time in seconds that the plan needed to run.
    /// </param>
    public static void RecordRuntime(UTAutomationPlan plan, float seconds)
    {
        var i     = 0;
        var found = false;

        do
        {
            var entry = EditorPrefs.GetString(PlanPrefix + i, "");
            if (string.IsNullOrEmpty(entry))
            {
                break;
            }
            if (entry == plan.Guid)
            {
                found = true;
                break;
            }
            i++;
        } while (true);


        var currentTime = EditorPrefs.GetFloat(PlanPrefix + i + ".time", 0f);

        if (UTPreferences.DebugMode)
        {
            Debug.Log("Recording " + seconds.ToString("0.00") + " for plan " + plan.Guid);
        }
        var newTime = seconds;

        if (found)
        {
            newTime = (currentTime + seconds) / 2f;
        }
        EditorPrefs.SetString(PlanPrefix + i, plan.Guid);
        EditorPrefs.SetFloat(PlanPrefix + i + ".time", newTime);
        EditorPrefs.SetString(PlanPrefix + i + ".lastModified", ToString(DateTime.Now));
        EditorPrefs.SetString(PlanPrefix + i + ".project", Application.dataPath);
    }
Example #18
0
    /// <summary>
    /// Loads a plan into this model.
    /// </summary>
    /// <param name='plan'>
    /// The plan to load.
    /// </param>
    public void LoadPlan(UTAutomationPlan plan)
    {
        if (plan != null)
        {
            data = plan;
            string path = PlanPath;
            graphData = null;
            selectedNodes.Clear();

            // objects with hide fagl are not returned by LoadAssetAtPath
            UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(path);
            foreach (UnityEngine.Object asset in assets)
            {
                if (asset is UTGraph)
                {
                    graphData = (UTGraph)asset;
                    break;
                }
            }
            if (graphData == null)
            {
                graphData      = UTils.AddAssetOfType <UTGraph> (path, true);
                graphData.name = "Graph";
                EditorUtility.SetDirty(graphData);
            }
            if (plan.firstEntry != null)
            {
                SelectNode(graphData.GetNodeFor(plan.firstEntry), SelectionMode.Add);
            }
        }
        else
        {
            data      = null;
            graphData = null;
            selectedNodes.Clear();
            highlightedNode = null;
        }
    }
    public static void RunPlan()
    {
        var plan = GetArg("-plan");

        if (plan == null)
        {
            throw new ArgumentException("You need to specify a -plan argument.");
        }


        UTAutomationPlan thePlan = UTomate.UTAutomationPlanByName(plan);

        if (thePlan == null)
        {
            throw new ArgumentException("There is no plan named '" + plan + "'");
        }

        var props     = GetArgs("-prop");
        var realProps = ParseProps(props);

        var debugMode = GetArg("-debugMode");

        if (debugMode == "true")
        {
            UTPreferences.DebugMode = true;
        }
        else
        {
            UTPreferences.DebugMode = false;
        }


        UTomateRunner.Instance.OnRunnerFinished += delegate(bool cancelled, bool failed) {
            EditorApplication.Exit(cancelled || failed ? 1 : 0);
        };

        UTomate.Run(thePlan, realProps);
    }
Example #20
0
    public void OnGUI()
    {
        EditorGUI.BeginChangeCheck();
        plan = EditorGUILayout.ObjectField(plan, typeof(UTAutomationPlan), false) as UTAutomationPlan;
        if (EditorGUI.EndChangeCheck())
        {
            RefreshInternals();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        UTNodeEditor.NodeEditor(editorData, editorModel, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

#if UTOMATE_DEMO
        if (Event.current.type == EventType.Repaint)
        {
            var lastRect = GUILayoutUtility.GetLastRect();
            var content  = new GUIContent("Demo Version");
            var size     = UTEditorResources.DemoVersionLabelStyle.CalcSize(content);
            lastRect.Set(lastRect.xMin + lastRect.width - size.x, lastRect.yMin, size.x, size.y);
            GUI.Label(lastRect, content, UTEditorResources.DemoVersionLabelStyle);
        }
#endif

        EditorGUILayout.BeginHorizontal();
        GUI.enabled = editorModel.HasPlan;
        if (GUILayout.Button("Layout"))
        {
            editorModel.RelayoutPlan();
        }
        GUI.enabled = true;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        // Inspector
        inspectorWidth = CUResizableContainer.BeginHorizontal(inspectorWidth, minInspectorWidth, 3 * minInspectorWidth, CUResizableContainer.HandlePosition.Before);
        EditorGUILayout.BeginVertical();

        editorData.inspectorScrollPosition = EditorGUILayout.BeginScrollView(editorData.inspectorScrollPosition);
        // current action.
        if (editorModel.SelectedEntry != null)
        {
            inspectorRenderer.target = editorModel.SelectedEntry;
            inspectorRenderer.OnInspectorGUI();
        }
        EditorGUILayout.EndScrollView();

        GUILayout.FlexibleSpace();

        // Render plan settings
        if (plan != null)
        {
            inspectorRenderer.target = plan;
            inspectorRenderer.OnInspectorGUI();
        }
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUI.enabled = plan != null;
        if (GUILayout.Button("Run this plan", EditorStyles.miniButton))
        {
            plan.Execute();
            GUIUtility.ExitGUI();
        }
        GUI.enabled = true;
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
        CUResizableContainer.EndHorizontal();
        // Inspector

        EditorGUILayout.EndHorizontal();

        if (UTomateRunner.Instance.IsRunning)
        {
            editorModel.HighlightedEntry = UTomateRunner.Instance.CurrentEntry;
            Repaint();
        }
        else
        {
            editorModel.HighlightedEntry = null;
        }
    }
	/// <summary>
	/// Run the specified plan.
	/// </summary>
	/// <param name='plan'>
	/// Plan to run.
	/// </param>
	public static void Run(UTAutomationPlan plan) {
		Run (plan, null);
	}
    /// <summary>
    /// Requests to run a certain plan. Only one plan can run at a time.
    /// </summary>
    /// <param name='plan'>
    /// The plan to run.
    /// </param>
    /// <param name='context'>
    /// Context in which the plan should run.
    /// </param>
    public void RequestRun(UTAutomationPlan plan, UTContext context)
    {
        #if UTOMATE_DEMO
        // when developing utomate demo locally we want to allow our own plans, so we set another flag which
        // removes this restriction for us.
        #if !UTOMATE_DEVELOPMENT_MODE
        if (UTomate.CheckPlanCountExceeded()) {
            return;
        }
        #endif
        #endif

        if (IsRunning) {
            throw new InvalidOperationException ("The runner is currently busy. Use IsRunning to check if the runner is busy, before invoking this.");
        }
        this.plan = plan;
        this.context = context;
        float expectedTimeInSeconds = 0;
        this.planWasRunBefore = UTStatistics.GetExpectedRuntime (plan, out expectedTimeInSeconds);
        this.expectedTime = TimeSpan.FromSeconds (expectedTimeInSeconds);
        UTPreferences.LastRunPlan = plan.name;
        planLookupDone = false;

        if (OnRunnerStarted != null) {
            OnRunnerStarted ();
        }
        // save all changes to assets before run.
        AssetDatabase.SaveAssets();
        EditorApplication.SaveAssets();

        // keep stuff running in background
        // this will overwrite playersettings implicitely, therefore we store the previous value here..
        playerSettingsRunInBackgroundValue = PlayerSettings.runInBackground;
        Application.runInBackground = true;
        // and set it back here... so we don't f**k up the settings that were set before running utomate.
        PlayerSettings.runInBackground = playerSettingsRunInBackgroundValue;
        this.reloadOfAssembliesLocked = false;
    }
Example #23
0
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to execute
 /// </param>
 static void ExecuteSelectedPlan(UTAutomationPlan plan)
 {
     plan.Execute();
 }
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to execute
 /// </param>
 static void ExecuteSelectedPlan(UTAutomationPlan plan)
 {
     plan.Execute ();
 }
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to locate
 /// </param>
 static void LocateSelectedPlan(UTAutomationPlan plan)
 {
     EditorGUIUtility.PingObject (plan);
 }
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to edit
 /// </param>
 static void EditSelectedPlan(UTAutomationPlan plan)
 {
     UTAutomationPlanWindow.EditAutomationPlan (plan);
 }
Example #27
0
    /// <summary>
    /// Adds a plan as a subplan to the automation plan at the given location. Internally creates a new automation
    /// plan entry and adds it to the auotmation plan. Also creates a <see cref="UTNode"/> instance representing the
    /// new automation plan entry.
    /// </summary>
    /// <param name='plan'>
    /// The plan to add.
    /// </param>
    /// <param name='position'>
    /// Position at which the plan should be added.
    /// </param>
    public void AddSubPlan(UTAutomationPlan plan, Vector2 position)
    {
        var entry = AddEntry <UTAutomationPlanPlanEntry> (position);

        entry.plan = plan;
    }
    private void CleanUp()
    {
        UTils.ClearAsyncProgressBar ();
        var cancelled = context.CancelRequested;
        var failed = context.Failed;
        context = null;
        enumerator = null;

        var endTime = DateTime.Now;
        var duration = endTime - startTime;
        if (!cancelled && !failed) { // recording cancelled runs will greatly diminish the accuracy of the statistics, so don't record them
            UTStatistics.RecordRuntime (plan, (float)duration.TotalSeconds);
        }
        plan = null;
        Debug.Log ("Automation finished in " + FormatTime (duration, false) + ".");
        if (cancelled) {
            Debug.LogWarning ("Run was canceled by user.");
        }
        if (failed) {
            Debug.LogError ("Run failed with error.");
        }

        if (OnRunnerFinished != null) {
            OnRunnerFinished (cancelled, failed);
        }

        // now check if the player settings were modified by an action, in this case we don't reset them
        var newBackgroundSetting = PlayerSettings.runInBackground;
        Application.runInBackground = false;

        // and reset it back if it wasn't so we don't f**k up what was set before..
        if (newBackgroundSetting == playerSettingsRunInBackgroundValue) {
            // not modified by an action, in this case reset it
            PlayerSettings.runInBackground = playerSettingsRunInBackgroundValue;
        }

        if (reloadOfAssembliesLocked) {
            Debug.Log("Releasing assembly reload lock now.");
            EditorApplication.UnlockReloadAssemblies ();
        }
        AssetDatabase.Refresh (); // make sure updates are shown in the editor.
    }
 /// <summary>
 /// Returns an estimation of the plan's run time from the history of previous runtimes.
 /// </summary>
 /// <returns>
 /// The expected runtime. If the plan never run before 0 is returned.
 /// </returns>
 /// <param name='plan'>
 /// The plan.
 /// </param>
 public static bool GetExpectedRuntime(UTAutomationPlan plan, out float time)
 {
     var i = 0;
     var found = false;
     do {
         var entry = EditorPrefs.GetString (PlanPrefix + i, "");
         if (string.IsNullOrEmpty (entry)) {
             break;
         }
         if (entry == plan.Guid) {
             found = true;
             break;
         }
         i++;
     } while (true);
     if (found) {
         time = EditorPrefs.GetFloat (PlanPrefix + i + ".time", 0f);
     } else {
         time = 0;
     }
     return found;
 }
Example #30
0
 /// <summary>
 /// Run the specified plan.
 /// </summary>
 /// <param name='plan'>
 /// Plan to run.
 /// </param>
 public static void Run(UTAutomationPlan plan)
 {
     Run(plan, null);
 }
Example #31
0
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to edit
 /// </param>
 static void EditSelectedPlan(UTAutomationPlan plan)
 {
     UTAutomationPlanWindow.EditAutomationPlan(plan);
 }
Example #32
0
 /// <summary>
 /// Callback for the popup window
 /// </summary>
 /// <param name='plan'>
 /// the plan to locate
 /// </param>
 static void LocateSelectedPlan(UTAutomationPlan plan)
 {
     EditorGUIUtility.PingObject(plan);
 }
    /// <summary>
    /// Records the runtime of an automation plan which allows making an estimation on the run time when the plan
    /// runs next time.
    /// </summary>
    /// <param name='plan'>
    /// The plan
    /// </param>
    /// <param name='seconds'>
    /// The time in seconds that the plan needed to run.
    /// </param>
    public static void RecordRuntime(UTAutomationPlan plan, float seconds)
    {
        var i = 0;
        var found = false;
        do {
            var entry = EditorPrefs.GetString (PlanPrefix + i, "");
            if (string.IsNullOrEmpty (entry)) {
                break;
            }
            if (entry == plan.Guid) {
                found = true;
                break;
            }
            i++;
        } while (true);

        var currentTime = EditorPrefs.GetFloat (PlanPrefix + i + ".time", 0f);
        if (UTPreferences.DebugMode) {
            Debug.Log ("Recording " + seconds.ToString ("0.00") + " for plan " + plan.Guid);
        }
        var newTime = seconds;
        if (found) {
            newTime = (currentTime + seconds) / 2f;
        }
        EditorPrefs.SetString (PlanPrefix + i, plan.Guid);
        EditorPrefs.SetFloat (PlanPrefix + i + ".time", newTime);
        EditorPrefs.SetString (PlanPrefix + i + ".lastModified", ToString (DateTime.Now));
        EditorPrefs.SetString (PlanPrefix + i + ".project", Application.dataPath);
    }
    public void OnGUI()
    {
        EditorGUI.BeginChangeCheck ();
        plan = EditorGUILayout.ObjectField (plan, typeof(UTAutomationPlan), false) as UTAutomationPlan;
        if (EditorGUI.EndChangeCheck ()) {
            RefreshInternals ();
        }

        EditorGUILayout.BeginHorizontal ();
        EditorGUILayout.BeginVertical();
        UTNodeEditor.NodeEditor (editorData, editorModel, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));

        #if UTOMATE_DEMO
        if(Event.current.type == EventType.Repaint) {
            var lastRect = GUILayoutUtility.GetLastRect();
            var content = new GUIContent("Demo Version");
            var size = UTEditorResources.DemoVersionLabelStyle.CalcSize(content);
            lastRect.Set(lastRect.xMin + lastRect.width - size.x, lastRect.yMin, size.x, size.y);
            GUI.Label(lastRect, content, UTEditorResources.DemoVersionLabelStyle);
        }
        #endif

        EditorGUILayout.BeginHorizontal();
        GUI.enabled = editorModel.HasPlan;
        if (GUILayout.Button("Layout")) {
            editorModel.RelayoutPlan();
        }
        GUI.enabled = true;
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space ();
        EditorGUILayout.EndVertical();

        // Inspector
        inspectorWidth = CUResizableContainer.BeginHorizontal (inspectorWidth, minInspectorWidth, 3 * minInspectorWidth, CUResizableContainer.HandlePosition.Before);
        EditorGUILayout.BeginVertical ();

        editorData.inspectorScrollPosition = EditorGUILayout.BeginScrollView (editorData.inspectorScrollPosition);
        // current action.
        if (editorModel.SelectedEntry != null) {
            inspectorRenderer.target = editorModel.SelectedEntry;
            inspectorRenderer.OnInspectorGUI ();
        }
        EditorGUILayout.EndScrollView ();

        GUILayout.FlexibleSpace ();

        // Render plan settings
        if (plan != null) {
            inspectorRenderer.target = plan;
            inspectorRenderer.OnInspectorGUI();
        }
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal ();
        GUILayout.FlexibleSpace();
        GUI.enabled = plan != null;
        if (GUILayout.Button ("Run this plan", EditorStyles.miniButton)) {
            plan.Execute ();
            GUIUtility.ExitGUI ();
        }
        GUI.enabled = true;
        EditorGUILayout.EndHorizontal ();
        EditorGUILayout.Space ();
        EditorGUILayout.EndVertical ();
        CUResizableContainer.EndHorizontal ();
        // Inspector

        EditorGUILayout.EndHorizontal ();

        if (UTomateRunner.Instance.IsRunning) {
            editorModel.HighlightedEntry = UTomateRunner.Instance.CurrentEntry;
            Repaint();
        }
        else {
            editorModel.HighlightedEntry = null;
        }
    }