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 #2
0
    public static void Create()
    {
#if UTOMATE_DEMO
        if (UTomate.CheckPlanCountExceeded())
        {
            return;
        }
#endif
        UTils.CreateAssetOfType <UTAutomationPlan> ("Automation Plan");
    }
Example #3
0
    private void RunSelected()
    {
        ShowTab();
        var selectedItems = listData.GetSelectedItems <UTAutomationPlan> (showHidden ? plans : visiblePlans);

        if (selectedItems.Count == 1)
        {
            UTomate.Run(selectedItems [0]);
        }
        RefreshInternals();          // build might change something, so better re-acquire all.
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        EditorGUILayout.Space();

        EditorGUILayout.HelpBox("You can directly run this plan from here.", MessageType.None);
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Run this plan"))
        {
            UTomate.Run(target as UTAutomationPlan);
        }
        EditorGUILayout.EndHorizontal();
    }
Example #5
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;
    }
Example #6
0
    private void DrawRunner()
    {
        GUILayout.Label("Runner", UTEditorResources.TitleStyle);

        var lastPlan = UTomateRunner.Instance.LastPlan;

        if (lastPlan != null && !UTomateRunner.Instance.IsRunning)
        {
            Rect boxRect = EditorGUILayout.BeginHorizontal(UTEditorResources.RunAgainBoxStyle);
            EditorGUI.HelpBox(boxRect, "Last executed plan: " + lastPlan.name, MessageType.None);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(UTEditorResources.RunAgainIcon, UTEditorResources.RunAgainButtonStyle))
            {
                UTomate.Run(lastPlan);
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();

        UTomateRunner.Instance.DrawGUI();

        if (!UTomateRunner.Instance.IsRunning)
        {
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUI.enabled = UTStatistics.HasStatistics();
            if (GUILayout.Button("Clear plan statistics"))
            {
                UTStatistics.Clear();
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        else
        {
            Repaint();
        }
    }
    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 #8
0
 public void Execute()
 {
     UTomate.Run(this);
 }
Example #9
0
 private static void LoadAutomationPlans(out List <UTAutomationPlan> allPlans, out List <UTAutomationPlan> visiblePlans)
 {
     allPlans     = UTomate.AllUTAutomationPlans();
     visiblePlans = allPlans.FindAll(x => !x.hideInExecutionWindow);
 }