示例#1
0
        /// <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();
        }
示例#2
0
    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);
    }
示例#3
0
    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);

        }
示例#5
0
 public QuickReference (string _identifier,VSCategory _categoryReference,VSTileGroup _group) {
     groupReference = _group;
     identifierName = _identifier;
     categoryReference = _categoryReference;
 }
示例#6
0
    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;

    }
示例#7
0
        /// <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();

        }
示例#8
0
 public QuickReference(string _identifier, VSCategory _categoryReference, VSTileGroup _group)
 {
     groupReference    = _group;
     identifierName    = _identifier;
     categoryReference = _categoryReference;
 }
示例#9
0
        /// <summary>
        /// When the group is changed.
        /// </summary>
        /// <param name="_itemGroup">the new group.</param>
        private void OnGroupChanged (VSTileGroup _itemGroup) {



        }
示例#10
0
        /// <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);
                            }
                        }
                    }
                }
            }
        }
示例#11
0
 /// <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();
 }
示例#12
0
 /// <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);
 }
示例#13
0
 /// <summary>
 /// When the group is changed.
 /// </summary>
 /// <param name="_itemGroup">the new group.</param>
 private void OnGroupChanged(VSTileGroup _itemGroup)
 {
 }