예제 #1
0
        GUIContent[] GetBuildStepProvidersParameterOptions(BuildStepProviderEntry entry)
        {
            List <GUIContent> outList = new List <GUIContent>();

            if (entry != null)
            {
                string[] entries = entry.GetParameterDropdownOptions();
                foreach (var option in entries)
                {
                    outList.Add(new GUIContent(option));
                }
            }

            return(outList.ToArray());
        }
예제 #2
0
        public BuildProcessEditor()
        {
            //
            // create list of available Build SteP Providers
            //
            mBuildStepProviders = UBS.Helpers.FindClassesImplementingInterface(typeof(IBuildStepProvider));
#if UBS_DEBUG
            Debug.Log("Found " + mBuildStepProviders.Count + " BuildStepProviders");
#endif
            mSelectableBuildStepProviders     = new BuildStepProviderEntry[mBuildStepProviders.Count + 1];
            mSelectableBuildStepProviders [0] = new BuildStepProviderEntry(null);
            for (int i = 0; i < mBuildStepProviders.Count; i++)
            {
                mSelectableBuildStepProviders [i + 1] = new BuildStepProviderEntry(mBuildStepProviders [i]);

#if UBS_DEBUG
                Debug.Log(">" + mBuildStepProviders[i].Name);
#endif
            }

            //
            // create list of available build targets
            //
        }
예제 #3
0
        UBS.BuildStep StepDrawer(UnityEngine.Rect pRect, UBS.BuildStep pStep)
        {
            if (pStep == null)
            {
                pStep = new BuildStep();
            }

            var filtered = new List <BuildStepProviderEntry>(mSelectableBuildStepProviders);

            filtered = filtered.FindAll((obj) => {
                if (obj.mName == "None")
                {
                    return(false);
                }
                return(obj.CheckFilters(mDrawingBuildStepType, mEditedBuildProcess.mPlatform));
            });

            int selectedIndex = 0;
            int listIndex     = 0;

            if (pStep.mTypeName != null)
            {
                pStep.InferType();
                listIndex     = filtered.FindIndex((obj) => { return(obj.mType == pStep.mType); });
                selectedIndex = listIndex + 1;
            }
            GUIContent[] displayedProviders = GetBuildStepProvidersFiltered();
            Rect         r1 = new Rect(pRect.x, pRect.y + 1, 140, pRect.height);                       // drop down list
            Rect         r2 = new Rect(r1.x + r1.width, pRect.y, 20, pRect.height);                    // gears
            Rect         r3 = new Rect(r2.x + r2.width, pRect.y, 70, pRect.height);                    // parameters label
            Rect         r4 = new Rect(r3.x + r3.width - 5, pRect.y, pRect.width - 230, pRect.height); // parameters input


            int idx = EditorGUI.Popup(r1, selectedIndex, displayedProviders);

            if (!EditorGUIUtility.isProSkin)
            {
                GUI.color = Color.black;
            }
            if (idx > 0 && GUI.Button(r2, Styles.gear, EditorStyles.miniLabel))
            {
                if (idx > 0)
                {
                    EditorUtility.DisplayDialog(
                        "Build Step Help",
                        displayedProviders [idx].text + "\n\n" + displayedProviders [idx].tooltip,
                        "Close"
                        );
                }
            }
            GUI.color = Color.white;
            //r.x += r.width;
            GUI.Label(r3, "Parameters", EditorStyles.miniLabel);

            //r.x += r.width;

            // search for buildstepprovider
            EBuildStepParameterType parametersToDisplay = EBuildStepParameterType.None;
            BuildStepProviderEntry  buildStepProvider   = null;

            if (listIndex >= 0 && listIndex < filtered.Count())
            {
                buildStepProvider   = filtered[listIndex];
                parametersToDisplay = buildStepProvider.GetParameterType();
            }

            switch (parametersToDisplay)
            {
            case EBuildStepParameterType.None:
            {
                // dont show anything!
            }
            break;

            case EBuildStepParameterType.String:
            {
                pStep.mParams = EditorGUI.TextField(r4, pStep.mParams);
            }
            break;

            case EBuildStepParameterType.Dropdown:
            {
                List <string> options       = new List <string>(buildStepProvider.GetParameterDropdownOptions());
                int           selectedValue = 0;
                if (!String.IsNullOrEmpty(pStep.mParams))
                {
                    selectedValue = options.FindIndex((option) => { return(option == pStep.mParams); });
                }

                if (selectedValue == -1)
                {
                    selectedValue = 0;                     // first index as fallback
                    Debug.LogError("Invalid dropdown entry found: " + pStep.mParams + " for buildstep: " + buildStepProvider.mName + ". Fallback to index 0 applied!");
                }

                // create popup control and assign selected index
                int returnedIndex = EditorGUI.Popup(r4, selectedValue, GetBuildStepProvidersParameterOptions(buildStepProvider));
                pStep.mParams = options[returnedIndex];
            }
            break;
            }

            if (idx != selectedIndex)
            {
                Undo.RecordObject(mCollection, "Set Build Step Class Reference");

                if (idx == 0)
                {
                    pStep.SetType(null);
                }
                else
                {
                    pStep.SetType(filtered [idx - 1].mType);
                }
            }

            return(pStep);
        }