Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public UnityScriptingHost(
            IScriptLoader loader,
            IScriptDependencyResolver resolver)
            : base(options => options.AllowClr())
        {
            Loader   = loader;
            Resolver = resolver;

            SetValue("Log", new UnityLogWrapper());
            SetValue("Scene", new UnitySceneManager());

            SetValue("require", new Func <string, JsValue>(Require));
            SetValue("inject", new Func <string, object>(Inject));
        }
Пример #2
0
        public ScriptsViewModel(UIServices uiServices, IScriptRunner scriptRunner,
                                IOperationProgress progress, IScriptDependencyResolver scriptDependencyResolver, IScriptParser parser, IDeploymentContext deploymentContext, IOperationContext operationContext)
        {
            this.uiServices               = uiServices;
            this.scriptRunner             = scriptRunner;
            this.scriptDependencyResolver = scriptDependencyResolver;
            this.parser            = parser;
            this.deploymentContext = deploymentContext;

            var canRun     = this.WhenAnyValue(x => x.SelectedScript).Select(s => s != null);
            var runCommand = ReactiveCommand.CreateFromTask(Run, canRun);

            RunCommand = new ProgressViewModel(runCommand, progress, this, this.uiServices.ContextDialog, operationContext);

            IsBusyObservable = Observable.Merge(RunCommand.Command.IsExecuting);

            Tree = GetTree(new DirectoryInfo(extraScriptsPath)).Children.ToList();

            MessageBus.Current.Listen <FolderNode>().Subscribe(x => SelectedScript = x);
        }