예제 #1
0
        private void AddMainPageSelects()
        {
            var             mainWindow  = NGUIDepthSetterMain.mainWindow;
            var             widgets     = mainWindow.PopSelectWidgets();
            List <UIWidget> needRemoves = new List <UIWidget>();

            foreach (var v in widgets)
            {
                bool needContinue = false;
                foreach (var l in DrawCalls)
                {
                    if (l.Push(v))
                    {
                        needRemoves.Add(v);
                        needContinue = true;
                        break;
                    }
                }
                if (needContinue)
                {
                    continue;
                }
                // new dc
                var dcn = MiniDrawCall.CreateNewDC(v);
                if (dcn != null)
                {
                    DrawCalls.Add(dcn);
                    needRemoves.Add(v);
                }
            }
            foreach (var v in needRemoves)
            {
                widgets.Remove(v);
            }
            // insert into empty dc
            foreach (var v in widgets)
            {
                EmptyDrawCall.Push(v);
            }
            mainWindow.Focus();
            this.Focus();
        }
예제 #2
0
 public static MiniDrawCall CreateNewDC(UIWidget w, bool Empty = false)
 {
     if (Empty)
     {
         var ret = new MiniDrawCall();
         ret.isEmpty = true;
         return(ret);
     }
     if (NGUIDepthSetterTools.CanDoDrawCall(w))
     {
         var ret = new MiniDrawCall();
         ret.widgetInformations.Add(new WidgetInformation()
         {
             widget = w
         });
         ret.mainTexture = w.mainTexture;
         ret.shader      = w.shader;
         ret.material    = w.material;
         return(ret);
     }
     return(null);
 }
예제 #3
0
        void DrawDrawCall(int i, int count, MiniDrawCall dc)
        {
            string key;
            string name;
            bool   isEmpty = dc.IsEmpty();

            if (isEmpty)
            {
                key  = "Empty DC";
                name = key;
            }
            else
            {
                key  = "DC " + (i + 1).ToString();
                name = key + " of " + count.ToString();
            }
            if (NGUIEditorTools.DrawHeader(name, key))
            {
                GUI.color = new Color(0.8f, 0.8f, 0.8f);
                NGUIEditorTools.BeginContents();
                GUILayout.BeginVertical();
                {
                    GUI.color = new Color(0.8f, 0.8f, 0.7f);
                    GUILayout.Label("Options");
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Depth增加规则");
                    dc.DepthSortStrategyIndex = (MiniDrawCall.DepthSortStrategy)EditorGUILayout.EnumPopup(dc.DepthSortStrategyIndex);
                    GUILayout.EndHorizontal();
                    if (dc.DepthSortStrategyIndex == MiniDrawCall.DepthSortStrategy.MidSame)
                    {
                        GUILayout.BeginVertical();
                        var it = EditorGUILayout.ObjectField("Begin", (UnityEngine.Object)dc.beginWidget, typeof(UIWidget), true) as UIWidget;
                        if (dc.IsContain(it))
                        {
                            if (it != dc.endWidget)
                            {
                                dc.beginWidget = it;
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("警告", "不能与End相同", "确定");
                            }
                        }
                        else if (it != null)
                        {
                            EditorUtility.DisplayDialog("警告", "请使用同一个DrawCall里的UIWidget", "确定");
                        }
                        it = EditorGUILayout.ObjectField("End", (UnityEngine.Object)dc.endWidget, typeof(UIWidget), true) as UIWidget;
                        if (dc.IsContain(it))
                        {
                            if (it != dc.beginWidget)
                            {
                                dc.endWidget = it;
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("警告", "不能与Begin相同", "确定");
                            }
                        }
                        else if (it != null)
                        {
                            EditorUtility.DisplayDialog("警告", "请使用同一个DrawCall里的UIWidget", "确定");
                        }
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndVertical();
                GUI.color = new Color(0.8f, 0.7f, 0.8f);
                GUILayout.BeginVertical();
                {
                    GUI.color = new Color(0.7f, 0.7f, 0.7f);
                    for (int j = 0; j < dc.widgetInformations.Count; ++j)
                    {
                        GUILayout.BeginHorizontal();
                        var w = dc.widgetInformations[j];
                        w.isSelect = GUILayout.Toggle(w.isSelect, "sel");
                        w.widget   = EditorGUILayout.ObjectField(w.widget, typeof(UIWidget), true) as UIWidget;
                        dc.widgetInformations[j] = w;
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndVertical();
                NGUIEditorTools.EndContents();
            }
        }