protected override List <IBuildSetting> GetAllParentSettings(int initialCapacity)
        {
            List <IBuildSetting> parentSettings = new List <IBuildSetting>(initialCapacity);
            IBuildSetting        parentSetting  = parentProperty.objectReferenceValue as IBuildSetting;

            while (parentSetting != null)
            {
                // Add the setting into the list
                parentSettings.Add(parentSetting);

                // Check if this setting has a parent
                if (parentSetting is IChildBuildSetting)
                {
                    // If so, grab it
                    parentSetting = ((IChildBuildSetting)parentSetting).Parent;
                }
                else
                {
                    // If not, terminate the loop
                    break;
                }
            }

            return(parentSettings);
        }
 protected void DrawBuildButton(string buttonText = "Build")
 {
     if (GUI.Button(EditorGUILayout.GetControlRect(), buttonText) == true)
     {
         IBuildSetting setting = target as IBuildSetting;
         if (setting != null)
         {
             BuildPlayersResult results = setting.Build();
             Debug.Log(results);
         }
     }
 }
Esempio n. 3
0
        protected void DrawButtons(Rect rect, UnityEngine.Object serializedObject)
        {
            // Unindent
            bool originalEnabled = GUI.enabled;

            rect.x     -= EditorUiUtility.IndentSpace;
            rect.width += EditorUiUtility.IndentSpace;

            // Update enabled stuff
            IBuildSetting setting = serializedObject as IBuildSetting;

            GUI.enabled = (setting != null);

            // Draw Edit Button
            rect.width -= (EditorUiUtility.VerticalMargin * 2);
            rect.width /= 3f;
            if (GUI.Button(rect, "Edit") == true)
            {
                // Select object
                Selection.activeObject = serializedObject;
            }

            // Draw Duplicate Button
            rect.x += EditorUiUtility.VerticalMargin;
            rect.x += rect.width;
            if (GUI.Button(rect, "Duplicate") == true)
            {
                // Duplicate object
                Duplicate(serializedObject.name + " (Clone)", serializedObject);
            }

            // Draw build button
            rect.x += EditorUiUtility.VerticalMargin;
            rect.x += rect.width;
            if (GUI.Button(rect, "Build") == true)
            {
                // Make a build
                Debug.Log(setting.Build());
            }
            GUI.enabled = originalEnabled;
        }
        protected override void OnHeaderGUI()
        {
            // Setup the title header
            using (new EditorGUILayout.VerticalScope("In BigTitle"))
            {
                // Draw the name of this asset
                GUILayout.Label(target.name, EditorStyles.largeLabel);

                // Draw a quick label indicating the purpose of this slider view
                GUILayout.Label("Navigation:", EditorStyles.miniBoldLabel, GUILayout.ExpandWidth(false));

                // Setup the scroll view
                using (EditorGUILayout.ScrollViewScope sScope = new EditorGUILayout.ScrollViewScope(scrollPos, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, GUIStyle.none, GUILayout.MinHeight(BackHeight)))
                    using (EditorGUILayout.HorizontalScope hScope = new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)))
                    {
                        // Starting with a list of size of 3 (latter number is arbitrary)
                        List <IBuildSetting> parentSettings = GetAllParentSettings(3);

                        if ((parentSettings != null) && (parentSettings.Count > 0))
                        {
                            // Go through the parent settings in reverse order
                            for (int index = (parentSettings.Count - 1); index >= 0; --index)
                            {
                                // Draw the button
                                IBuildSetting parentSetting = parentSettings[index];
                                if (GUILayout.Button(parentSetting.name, EditorStyles.foldout, GUILayout.ExpandWidth(false)) == true)
                                {
                                    Selection.activeObject = parentSetting;
                                }
                            }
                        }

                        // Draw a normal text
                        GUILayout.Label(target.name, EditorStyles.foldout, GUILayout.ExpandWidth(false));

                        // Update scroll position
                        scrollPos = sScope.scrollPosition;
                    }
            }
        }