/// <summary> /// Draws the Add and Remove TileGroup buttons. /// </summary> private void DrawListModifyPanel() { newGroupName = EditorGUILayout.TextField(newGroupName); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove")) { VSTileGroup group = swatchReference.GetGroupByShortenedName(newGroupName); if (group == null) { Debug.LogError("[VoxelSwatch Editor - Removing TileGroup]: not found TileGroup by name: " + newGroupName); } else { swatchReference.categories[categoryIndex].RemoveByName(newGroupName); UpdateGroupList(); } } if (GUILayout.Button("Add")) { if (swatchReference.categories[categoryIndex].CheckGroup(newGroupName) == null) { swatchReference.categories[categoryIndex].CreateNewTileGroup(newGroupName); UpdateGroupList(); } } EditorGUILayout.EndHorizontal(); }
public void CreateNewTileGroup(string _groupName) { //Create a new prefab at path GameObject newTileObject = new GameObject(_groupName + "_01"); GameObject prefab = PrefabUtility.CreatePrefab(directoryPath + "/" + newTileObject.name + ".prefab", newTileObject); VSTileGroup group = AddItemGroup(newTileObject, _groupName, 0); voxelSwatchReference.references.Add(new QuickReference(_groupName + "_01", this, group)); group.styles[0] = prefab; Object.DestroyImmediate(newTileObject); }
VSTileGroup CheckGroupRecursive(string _groupName) { for (int i = 0; i < tilegroups.Count; i++) { if (tilegroups[i].groupName == _groupName) { return(tilegroups[i]); } } VSTileGroup group = new VSTileGroup(_groupName, this); tilegroups.Add(group); return(group); }
/// <summary> /// Called when a tile group is selected in the search panel. /// </summary> /// <param name="_index">The index of the item in its original list.</param> private void OnTileGroupSelected (int _index) { selectedTileGroup = swatchReference.categories[categoryIndex].tilegroups[_index]; OnGroupChanged(selectedTileGroup); }
public QuickReference (string _identifier,VSCategory _categoryReference,VSTileGroup _group) { groupReference = _group; identifierName = _identifier; categoryReference = _categoryReference; }
VSTileGroup CheckGroupRecursive (string _groupName) { for (int i = 0; i < tilegroups.Count; i++) { if (tilegroups[i].groupName == _groupName) { return tilegroups[i]; } } VSTileGroup group = new VSTileGroup(_groupName,this); tilegroups.Add(group); return group; }
/// <summary> /// Called when the TileGroup is changed in the VSESwatchCategoryPanel. /// </summary> /// <param name="_group">The new TileGroup.</param> public void OnTileGroupChanged (VSTileGroup _group) { currentTileGroup = _group; UpdateStyleList(); }
public QuickReference(string _identifier, VSCategory _categoryReference, VSTileGroup _group) { groupReference = _group; identifierName = _identifier; categoryReference = _categoryReference; }
/// <summary> /// When the group is changed. /// </summary> /// <param name="_itemGroup">the new group.</param> private void OnGroupChanged (VSTileGroup _itemGroup) { }
/// <summary> /// Tries to switch the tile to another style of that tile. /// </summary> private void TryToSwitchTileStyle() { //Get the tile i'm pointing at. GameObject target = VMEGlobal.GetTileAtMousePosition(); if (target == null) { Debug.LogWarning("[Edit Mode - SwapStyle]: No target selected."); } else { VSTileGroup group = voxelSwatchReference.GetSwatch().GetGroupByName(target.name); if (group == null) { Debug.LogWarning("[Edit Mode - SwapStyle]: This tile is not a item from the VoxelSwatch. Style swap not possible."); } else { GameObject[] itemsInGroup = group.styles.ToArray(); if (itemsInGroup.Length == 1) { Debug.LogWarning("[Edit Mode - SwapStyle]: The Tile of type: " + target.name + " Only has one variation."); } else { int currentIndexInGroup = -1; Debug.Log("Items in the group: " + itemsInGroup.Length); for (int i = 0; i < itemsInGroup.Length; i++) { if (target.name == itemsInGroup[i].name) { currentIndexInGroup = i; Debug.Log(currentIndexInGroup); } } int newIndex = -1; if (currentIndexInGroup != -1) { Debug.Log(currentIndexInGroup + " : " + itemsInGroup.Length); if (currentIndexInGroup + 1 == itemsInGroup.Length) { newIndex = 0; } else { newIndex = currentIndexInGroup + 1; } if (currentIndexInGroup != newIndex) { VMEMainWindow.Instance.tileAddControls.EditTile(itemsInGroup[newIndex].gameObject, target); } } } } } }
/// <summary> /// Called when the TileGroup is changed in the VSESwatchCategoryPanel. /// </summary> /// <param name="_group">The new TileGroup.</param> public void OnTileGroupChanged(VSTileGroup _group) { currentTileGroup = _group; UpdateStyleList(); }
/// <summary> /// Called when a tile group is selected in the search panel. /// </summary> /// <param name="_index">The index of the item in its original list.</param> private void OnTileGroupSelected(int _index) { selectedTileGroup = swatchReference.categories[categoryIndex].tilegroups[_index]; OnGroupChanged(selectedTileGroup); }
/// <summary> /// When the group is changed. /// </summary> /// <param name="_itemGroup">the new group.</param> private void OnGroupChanged(VSTileGroup _itemGroup) { }