Example #1
0
    public void BuildFreshProcess()
    {
        DisableBuildUI();
        RevertDelegate revertable = DefaultStatebuildEnabled;

        revertable += buildManager.StopBuild;
        enableRevertUI(revertable);
    }
Example #2
0
    public void BuildProcess()
    {
        if (!baseRef.CanBuildBase())
        {
            return;
        }

        baseRef.RequiredToBuild();

        // disable UI (except return arrow).
        baseUI.SetActive(false);

        //enable return arrow, add functions to revert delegate
        RevertDelegate revertable = DefaultStateBaseUIEnabled;

        revertable += buildManager.StopBuild;
        enableRevertUI(revertable);

        buildManager.BeginBuild(baseRef, false);
    }
Example #3
0
 public void enableRevertUI(RevertDelegate revertable)
 {
     revertUI.SetActive(true);
     revert = revertable;
 }
        static Vector2 DrawRevertList(Vector2 scrollPosition, SerializedProperty list, int listHeight, RevertDelegate OnRevert, string[] drawPropertiesList = null)
        {
            if (list.arraySize == 0)
            {
                return(scrollPosition);
            }
            // Split and converted materials
            int   linesPerEntry = 1 + (drawPropertiesList != null ? drawPropertiesList.Length : 0);
            float height        = Styles.s_defaultLabel.fixedHeight * linesPerEntry;

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(listHeight));

            scrollPosition.y = Mathf.Min(height * list.arraySize, scrollPosition.y);
            for (int i = 0, c = list.arraySize; i < c; i++)
            {
                // create a 'window' of items to actually fill in, otherwise rendering the list is too slow
                int topIndex = (int)(scrollPosition.y / height);
                int start    = (int)(Mathf.Max(0f, topIndex - 4f));
                int end      = (int)(Mathf.Min(list.arraySize - 1, topIndex + 40f));

                if (i < start || i > end)
                {
                    // fill this item with blank space to save time
                    GUILayout.Space(Styles.s_defaultLabel.fixedHeight * linesPerEntry);
                    continue;
                }

                SerializedProperty element = list.GetArrayElementAtIndex(i);


                EditorGUILayout.BeginHorizontal();

                // print index
                GUILayout.Label("" + i, Styles.s_defaultLabel, GUILayout.Width(20));

                EditorGUILayout.PropertyField(element.FindPropertyRelative("m_material"), GUILayout.Height(Styles.s_defaultLabel.fixedHeight));

                if (GUILayout.Button("Revert", GUILayout.Width(60), GUILayout.Height(Styles.s_defaultLabel.fixedHeight)))
                {
                    OnRevert(element, i);

                    // if last item is visible and we delete something Unity throws a repaint exception, trying to repaint a list item thats not there anymore
                    if (list.arraySize - 1 == end)
                    {
                        scrollPosition.y -= height;
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (drawPropertiesList != null)
                {
                    for (int prop = 0; prop < drawPropertiesList.Length; ++prop)
                    {
                        EditorGUILayout.PropertyField(element.FindPropertyRelative("m_sourceScenePath"), GUILayout.Height(Styles.s_defaultLabel.fixedHeight));
                    }
                }
            }
            EditorGUILayout.EndScrollView();


            return(scrollPosition);
        }