Exemple #1
0
        public void OnEnable()
        {
            PWGUI = new PWGUIManager();

            reorderableSwitchDataList = new ReorderableList(switchDatas, typeof(BiomeSwitchData), true, true, true, true);

            reorderableSwitchDataList.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4;             //padding

            reorderableSwitchDataList.drawElementCallback = DrawElementCallback;

            reorderableSwitchDataList.drawHeaderCallback = (rect) => {
                EditorGUI.LabelField(rect, "switches");
            };

            reorderableSwitchDataList.onReorderCallback += (ReorderableList l) => {
                OnBiomeDataReordered();
            };

            reorderableSwitchDataList.onAddCallback += (ReorderableList l) => {
                BiomeSwitchData bsd        = new BiomeSwitchData(currentSampler, currentSamplerName);
                BiomeSwitchData lastSwitch = switchDatas.Last();
                bsd.min = lastSwitch.min + (lastSwitch.max - lastSwitch.min) / 2;
                switchDatas.Add(bsd);
                OnBiomeDataAdded(bsd);
            };

            reorderableSwitchDataList.onRemoveCallback += (ReorderableList l) => {
                if (switchDatas.Count > 1)
                {
                    switchDatas.RemoveAt(l.index);
                    OnBiomeDataRemoved();
                }
            };

            //add at least one biome switch:
            if (switchDatas.Count == 0)
            {
                switchDatas.Add(new BiomeSwitchData(currentSampler, currentSamplerName));
            }
        }