Exemple #1
0
        private unsafe void Refresh()
        {
            NameTable0.Lock();
            var nameTable0Ptr = NameTable0.BackBuffer;

            Engine.DrawNameTable((byte *)nameTable0Ptr.ToPointer(), 0);

            NameTable0.AddDirtyRect(new Int32Rect(0, 0, 256, 240));
            NameTable0.Unlock();


            if (Engine.IsVerticalMirroringEnabled)
            {
                NameTable1.Lock();
                var nameTable1Ptr = NameTable1.BackBuffer;

                Engine.DrawNameTable((byte *)nameTable1Ptr.ToPointer(), 1);

                NameTable1.AddDirtyRect(new Int32Rect(0, 0, 256, 240));
                NameTable1.Unlock();
            }
            else
            {
                NameTable2.Lock();
                var nameTable2Ptr = NameTable2.BackBuffer;

                Engine.DrawNameTable((byte *)nameTable2Ptr.ToPointer(), 2);

                NameTable2.AddDirtyRect(new Int32Rect(0, 0, 256, 240));
                NameTable2.Unlock();
            }

            RaisePropertyChanged("NameTable0");
            RaisePropertyChanged("NameTable1");
            RaisePropertyChanged("NameTable2");
            RaisePropertyChanged("NameTable3");
        }
Exemple #2
0
        public override void OnInspectorGUI()
        {
            //获取脚本对象
            NameTable2 script = target as NameTable2;

            EditorGUILayout.LabelField("数量:" + script._Size);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("+"))
            {
                Undo.RegisterCompleteObjectUndo(script, "NameTable2");
                script._Size += 1;
            }
            if (GUILayout.Button("-"))
            {
                Undo.RegisterCompleteObjectUndo(script, "NameTable2");
                script._Size -= 1;
                if (script._Size < 0)
                {
                    script._Size = 0;
                }
            }
            if (GUILayout.Button("排序"))
            {
                Undo.RegisterCompleteObjectUndo(script, "NameTable2");
                List <string>     keyList   = script._keys;
                List <GameObject> valueList = script._values;
                // 冒泡
                for (int key1 = 0; key1 < keyList.Count; key1++)
                {
                    for (int key = 0; key < keyList.Count - key1 - 1; key++)
                    {
                        if (keyList[key].CompareTo(keyList[key + 1]) > 0)
                        {
                            Swap(keyList, key, key + 1);
                            Swap(valueList, key, key + 1);
                        }
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            if (script._keys == null)
            {
                script._keys   = new List <string>();
                script._values = new List <GameObject>();
            }
            int i = 0;

            for (i = 0; i < script._Size; i++)
            {
                if (i >= script._keys.Count)
                {
                    script._keys.Add("");
                    script._values.Add(null);
                }
                EditorGUILayout.BeginHorizontal();
                script._keys[i]   = EditorGUILayout.TextField(script._keys[i]);
                script._values[i] = EditorGUILayout.ObjectField(script._values[i], typeof(GameObject), true) as GameObject;
                if (GUILayout.Button("X"))
                {
                    Undo.RegisterCompleteObjectUndo(script, "NameTable2");
                    script._Size -= 1;
                    script._keys.RemoveAt(i);
                }
                EditorGUILayout.EndHorizontal();
            }
            script._keys.RemoveRange(i, script._keys.Count - i);
            script._values.RemoveRange(i, script._values.Count - i);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
        }