示例#1
0
        public bool OnGUI(ref bool _dnaDirty, ref bool _textureDirty, ref bool _meshDirty)
        {
            bool changed = false;

            // Have to be able to assign a race on a new recipe.
            RaceData newRace = (RaceData)EditorGUILayout.ObjectField("RaceData", _recipe.raceData, typeof(RaceData), false);

            if (_recipe.raceData == null)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.55f, 0.25f, 0.25f));
                GUILayout.Label("Warning: No race data is set!");
                GUIHelper.EndVerticalPadded(10);
            }


            if (_recipe.raceData != newRace)
            {
                _recipe.SetRace(newRace);
                changed = true;
            }

            if (GUILayout.Button("Remove Nulls"))
            {
                var newList = new List <SlotData>(_recipe.slotDataList.Length);
                foreach (var slotData in _recipe.slotDataList)
                {
                    if (slotData != null)
                    {
                        newList.Add(slotData);
                    }
                }
                _recipe.slotDataList = newList.ToArray();
                changed       |= true;
                _dnaDirty     |= true;
                _textureDirty |= true;
                _meshDirty    |= true;
            }

            if (_sharedColorsEditor.OnGUI(_recipe))
            {
                changed       = true;
                _textureDirty = true;
            }

            var added = (SlotDataAsset)EditorGUILayout.ObjectField("Add Slot", null, typeof(SlotDataAsset), false);

            if (added != null)
            {
                var slot = new SlotData(added);
                _recipe.MergeSlot(slot, false);
                changed       |= true;
                _dnaDirty     |= true;
                _textureDirty |= true;
                _meshDirty    |= true;
            }

            for (int i = 0; i < _slotEditors.Count; i++)
            {
                var editor = _slotEditors[i];

                if (editor == null)
                {
                    GUILayout.Label("Empty Slot");
                    continue;
                }

                changed |= editor.OnGUI(ref _dnaDirty, ref _textureDirty, ref _meshDirty);

                if (editor.Delete)
                {
                    _dnaDirty     = true;
                    _textureDirty = true;
                    _meshDirty    = true;

                    _slotEditors.RemoveAt(i);
                    _recipe.SetSlot(editor.idx, null);
                    i--;
                    changed = true;
                }
            }

            return(changed);
        }
示例#2
0
        private void AddSlotDataAsset(SlotDataAsset added)
        {
            var slot = new SlotData(added);

            _recipe.MergeSlot(slot, false);
        }