static int MoveState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UI.StateHandle obj  = (UI.StateHandle)ToLua.CheckObject(L, 1, typeof(UI.StateHandle));
         int            arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         bool           arg1 = LuaDLL.luaL_checkboolean(L, 3);
         obj.MoveState(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Esempio n. 2
0
        //绘制状态
        void DrawState(StateHandle.State s, int idx)
        {
            if (!EditorUtil.DrawHeader("状态-" + s.name, "StateHandle_state_" + idx))
            {
                return;
            }

            bool syncGo = idx == m_cur.m_curState;//如果改变值的话要不要改变游戏变量

            using (new AutoContent())
            {
                //状态的信息
                using (new AutoBeginHorizontal())
                {
                    GUI.changed = false;
                    s.name      = EditorGUILayout.TextField("名字", s.name);//名字
                    using (new AutoLabelWidth(30))
                    {
                        s.isDuration = EditorGUILayout.Toggle("渐变", s.isDuration, GUILayout.Width(45));//渐变
                    }
                    //上移
                    if (m_cur.CanMoveState(idx, true) && GUILayout.Button("上移", GUILayout.Width(40)))
                    {
                        m_cur.MoveState(idx, true);
                        return;
                    }
                    //下移
                    if (m_cur.CanMoveState(idx, false) && GUILayout.Button("下移", GUILayout.Width(40)))
                    {
                        m_cur.MoveState(idx, false);
                        return;
                    }
                    if (GUILayout.Button("删除", GUILayout.Width(40)))
                    {
                        m_cur.RemoveState(idx);
                        return;
                    }

                    if (GUI.changed)
                    {
                        EditorUtil.SetDirty(m_cur);
                    }
                }
                using (new AutoBeginHorizontal()) //音效,位置不够另起一行
                {
                    EditorGUILayout.LabelField("音效", GUILayout.Width(85));
                    using (new AutoLabelWidth(30))
                    {
                        s.isEnterSound = EditorGUILayout.Toggle("进入", s.isEnterSound, GUILayout.Width(45));
                        if (s.isEnterSound)
                        {
                            int.TryParse(EditorGUILayout.TextField("ID", s.enterSoundId.ToString(), GUILayout.Width(60)), out s.enterSoundId);
                        }
                    }

                    using (new AutoLabelWidth(30))
                    {
                        s.isExitSound = EditorGUILayout.Toggle("离开", s.isExitSound, GUILayout.Width(45));
                        if (s.isExitSound)
                        {
                            int.TryParse(EditorGUILayout.TextField("ID", s.exitSoundId.ToString(), GUILayout.Width(60)), out s.exitSoundId);
                        }
                    }
                }

                //共有操作,不用画对象,也不能在这删除它
                for (int i = 0; i < s.publicHandles.Count; ++i)
                {
                    Handle h = s.publicHandles[i];
                    if (h.CurHandle == null)
                    {
                        //Debuger.LogError("没有处理");
                        continue;
                    }

                    using (new AutoBeginHorizontal())
                    {
                        EditorGUILayout.LabelField(h.CurTypeName, GUILayout.Width(85));
                        using (new AutoBeginVertical())
                        {
                            using (new AutoLabelWidth(50))
                            {
                                h.CurHandle.OnDrawMin(m_cur, h, SimpleHandleEditor.OnOpenWnd, syncGo);
                            }
                        }
                    }
                }

                //私有操作
                for (int i = 0; i < s.privateHandles.Count; ++i)
                {
                    Handle h = s.privateHandles[i];
                    if (h.CurHandle == null)
                    {
                        //Debuger.LogError("没有处理");
                        continue;
                    }

                    //对象和删除操作
                    using (new AutoBeginHorizontal())
                    {
                        //游戏对象改变
                        if (h.CurHandle.OnDrawGo(m_cur, h, h.CurTypeName))
                        {
                            h.CurHandle.OnReset(h, false, true);
                        }

                        //删除
                        if (GUILayout.Button("删除", GUILayout.Width(40)))
                        {
                            m_cur.RemovePrivateHandle(idx, i);
                            return;
                        }
                    }
                    //内容
                    using (new AutoBeginHorizontal())
                    {
                        EditorGUILayout.LabelField("", GUILayout.Width(85));
                        using (new AutoBeginVertical())
                        {
                            using (new AutoLabelWidth(50))
                            {
                                h.CurHandle.OnDrawMin(m_cur, h, SimpleHandleEditor.OnOpenWnd, syncGo);
                            }
                        }
                    }
                }

                //增加私有操作
                int type = UnityEditor.EditorGUILayout.Popup("增加私有操作", -1, Handle.TypeName);
                if (type != -1 && type != 0)
                {
                    m_cur.AddPrivateHandle(idx, (Handle.Type)type);
                }
            }
        }