Exemple #1
0
        public override void Initialize()
        {
            ModHooks.Instance.HeroUpdateHook += Instance_HeroUpdateHook;

            DebugScript.AddWindow <WTools>();

            WTools.AddTool <WGameObjectList>("游戏对象表");
            WTools.AddTool <WCompList>("组件表");
            WTools.AddTool <WValueList>("属性表");
            WTools.AddTool <WTool>("快捷工具");
        }
Exemple #2
0
 public void OnDestory()
 {
     Instance = null;
 }
Exemple #3
0
        public override void OnPaint()
        {
            PropertyInfo[] propertyInfos = EditObject.GetType().GetProperties();

            FieldInfo[] fieldInfos = EditObject.GetType()
                                     .GetFields();

            List <MemberInfo> memlist = new List <MemberInfo>(propertyInfos);

            foreach (var v in fieldInfos)
            {
                memlist.Add(v);
            }
            if (GUI.Button(new Rect(0, 20, Rect.width, 20), "关闭"))
            {
                IsShow = false;
                if (isDynCreate)
                {
                    NoUse = true;
                }
                return;
            }
            vector2 = GUI.BeginScrollView(new Rect(new Vector2(0, 40),
                                                   new Vector2(Rect.width, Rect.height - 40)), vector2,
                                          new Rect(
                                              0,
                                              0,
                                              Rect.width,
                                              (memlist.Count + 1) * 32));
            for (int i = 0; i < memlist.Count; i++)
            {
                int        y = (i + 1) * 32;
                MemberInfo o = memlist[i];
                try
                {
                    object value = null;
                    string name  = null;
                    Type   type  = null;
                    if ((o as FieldInfo) != null)
                    {
                        value = ((FieldInfo)o).GetValue(EditObject);
                        type  = ((FieldInfo)o).FieldType;
                        name  = ((FieldInfo)o).Name;
                    }
                    else
                    {
                        value = ((PropertyInfo)o).GetValue(EditObject, null);
                        type  = ((PropertyInfo)o).PropertyType;
                        name  = ((PropertyInfo)o).Name;
                    }

                    if (openedVL.ContainsKey(name))
                    {
                        WValueList wValueList = openedVL[name];

                        if (wValueList.isChanged)
                        {
                            if ((o as FieldInfo) != null)
                            {
                                ((FieldInfo)o).SetValue(EditObject, wValueList.EditObject);
                            }
                            else
                            {
                                ((PropertyInfo)o).SetValue(EditObject,
                                                           wValueList.EditObject, null);
                            }
                            wValueList.isChanged = false;
                        }
                        if (wValueList.NoUse)
                        {
                            openedVL.Remove(name);
                        }
                    }

                    string vstring = value.ToString();
                    if (vstring.Length >= 15)
                    {
                        vstring = vstring.Substring(0, 12) + "...";
                    }
                    GUI.Label(new Rect(0, y, Rect.width, 32),
                              o.Name
                              + " : "
                              + vstring);
                    if (Types.ContainsKey(type.FullName))
                    {
                        if (GUI.Button(new Rect(Rect.width - 96, y, 48, 32), "更改"))
                        {
                            Types[type.FullName]
                                (EditObject,
                                o,
                                value,
                                this);
                        }
                    }
                    if (GUI.Button(new Rect(Rect.width - 48, y, 48, 32), "查看"))
                    {
                        if (!openedVL.ContainsKey(name))
                        {
                            WValueList wValueList = DebugScript.AddWindow <WValueList>();
                            wValueList.EditObject  = value;
                            wValueList.isDynCreate = true;
                            openedVL[name]         = wValueList;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            GUI.EndScrollView();
        }
Exemple #4
0
 public void Awake()
 {
     Instance = this;
 }