Ejemplo n.º 1
0
        void ButlerNotInstalledGUI()
        {
            GUILayout.Label("Butler not detected. Press the button to download.");

            if (GUILayout.Button("Download Butler"))
            {
                _butler.DownloadButler((x) =>
                {
                    EditorUtility.DisplayProgressBar("Downloading Butler", "", x);
                }, EditorUtility.ClearProgressBar);
            }
        }
Ejemplo n.º 2
0
        public void CreateGUI()
        {
            InitializeButlerIfNecessary();

            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(MainStyleSheet);

            if (!IsEditorSupported())
            {
                var platformNotSupported = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(WrongPlatformUXML).CloneTree();
                platformNotSupported.styleSheets.Add(styleSheet);
                ShowPage(platformNotSupported);
                return;
            }

            // Create Download Page
            _downloadPage = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(DownloadUXML).CloneTree();
            _downloadPage.styleSheets.Add(styleSheet);

            var downloadButton   = _downloadPage.Q <Button>("downloadButton");
            var downloadProgress = _downloadPage.Q <ProgressBar>("downloadProgress");

            downloadProgress.visible = false;
            downloadButton.clicked  += () =>
            {
                downloadProgress.visible = true;
                _butler.DownloadButler(
                    progress => downloadProgress.value = progress,
                    onComplete: () => ShowPage(_sharePage));
            };

            // Create Share Page
            var settingsSo = new SerializedObject(_settings);

            // Import Share UXML
            _sharePage = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(ShareUXML).CloneTree();
            _sharePage.styleSheets.Add(styleSheet);

            // Authenticate Butler
            _sharePage.Q <Button>("auth").clicked   += _butler.Login;
            _sharePage.Q <Button>("deAuth").clicked += () => SetConsoleContents(_butler.Logout());
            _sharePage.Q <Button>("update").clicked += () => SetConsoleContents(_butler.CheckForUpdates());


            _sharePage.Q <EnumField>("buildTarget").BindProperty(settingsSo.FindProperty("BuildTarget"));
            // Account, Project & URL
            var acct = _sharePage.Q <TextField>("account");

            acct.BindProperty(settingsSo.FindProperty("Account"));
            var prjct = _sharePage.Q <TextField>("project");

            prjct.BindProperty(settingsSo.FindProperty("Project"));
            var urlDisplay = _sharePage.Q <Label>("projectUrl");

            urlDisplay.RegisterCallback <MouseUpEvent>((cb) => Application.OpenURL(_settings.GetURL()));
            urlDisplay.text = _settings.GetURL();
            acct.RegisterValueChangedCallback((_) => urlDisplay.text  = _settings.GetURL());
            prjct.RegisterValueChangedCallback((_) => urlDisplay.text = _settings.GetURL());

            // Channel
            var channel = _sharePage.Q <TextField>("channel");

            channel.BindProperty(settingsSo.FindProperty("Channel"));
            var overrideChannel = _sharePage.Q <Toggle>("overrideChannel");

            overrideChannel.BindProperty(settingsSo.FindProperty("OverrideChannel"));
            channel.visible = overrideChannel.value;
            overrideChannel.RegisterValueChangedCallback((x) => channel.visible = x.newValue);
            // Version
            var version = _sharePage.Q <TextField>("version");

            version.BindProperty(settingsSo.FindProperty("Version"));
            var overrideVersion = _sharePage.Q <Toggle>("overrideVersion");

            overrideVersion.BindProperty(settingsSo.FindProperty("OverrideVersion"));
            version.visible = overrideVersion.value;
            overrideVersion.RegisterValueChangedCallback((x) => version.visible = x.newValue);

            //buildPath
            var buildPath = _sharePage.Q <TextField>("buildPath");

            buildPath.BindProperty(settingsSo.FindProperty("BuildPath"));
            var overridebuildPath = _sharePage.Q <Toggle>("overrideBuildPath");

            buildPath.visible = overridebuildPath.value;
            overridebuildPath.RegisterValueChangedCallback((x) => buildPath.visible = x.newValue);


            _devBuildToggle = _sharePage.Q <Toggle>("devBuild");
            _devBuildToggle.SetValueWithoutNotify(EditorUserBuildSettings.development);
            _devBuildToggle.RegisterValueChangedCallback((x) => EditorUserBuildSettings.development = x.newValue);

            // Build button
            var buildButton = _sharePage.Q <Button>("build");

            buildButton.clicked += Build;

            // Console
            _console            = _sharePage.Q <TextField>("console");
            _console.isReadOnly = true;

            // Initialize page
            if (!_butler.IsInstalled)
            {
                ShowPage(_downloadPage);
                return;
            }
            ShowPage(_sharePage);
        }