public static void pickTile(Vector3 position)
    {
        if (YuME_mapEditor.findTileMapParent())
        {
            GameObject currentLayer = YuME_mapEditor.mapLayers[YuME_mapEditor.currentLayer - 1];
            Vector3    tempVec3;

            for (int i = 0; i < currentLayer.transform.childCount; ++i)
            {
                tempVec3 = currentLayer.transform.GetChild(i).transform.position;

                if (tempVec3.x == position.x && tempVec3.z == position.z && tempVec3.y >= position.y && tempVec3.y < position.y + 1f)
                {
                    YuME_mapEditor.currentTile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(currentLayer.transform.GetChild(i).gameObject)), typeof(GameObject)) as GameObject;

                    float pickRotation = 0;

                    if (currentLayer.transform.GetChild(i).transform.eulerAngles.y > 0)
                    {
                        pickRotation = currentLayer.transform.GetChild(i).eulerAngles.y;
                    }

                    YuME_mapEditor.currentBrushIndex = Array.IndexOf(YuME_mapEditor.currentTileSetObjects, YuME_mapEditor.currentTile);
                    YuME_mapEditor.currentTile.transform.localScale = currentLayer.transform.GetChild(i).gameObject.transform.localScale;
                    YuME_mapEditor.tileRotation = pickRotation;
                    YuME_brushFunctions.updateBrushTile();
                    YuME_mapEditor.selectedTool = YuME_mapEditor.toolIcons.brushTool;

                    return;
                }
            }
        }
    }
Пример #2
0
 public static void setTileBrush(int index)
 {
     currentBrushIndex = index;
     currentBrushType  = brushTypes.standardBrush;
     currentTile       = currentTileSetObjects[index];
     tileRotation      = 0f;
     YuME_brushFunctions.updateBrushTile();
     selectedTool = toolIcons.brushTool;
 }
Пример #3
0
 public static void setActiveMap()
 {
     for (int i = 0; i < YuME_mapEditor.ref_MapManager.mapList.Count; i++)
     {
         if (YuME_mapEditor.ref_MapManager.mapList[i] != null)
         {
             YuME_mapEditor.ref_MapManager.mapList[i].SetActive(false);
         }
     }
     YuME_mapEditor.ref_MapManager.mapList[YuME_mapEditor.currentMapIndex].SetActive(true);
     YuME_brushFunctions.updateBrushTile();
 }
Пример #4
0
    public static void pickTile(Vector3 position)
    {
        if (YuME_mapEditor.findTileMapParent())
        {
            GameObject currentLayer = YuME_mapEditor.mapLayers[YuME_mapEditor.currentLayer - 1];
            Vector3    tempVec3;

            for (int i = 0; i < currentLayer.transform.childCount; ++i)
            {
                tempVec3 = currentLayer.transform.GetChild(i).transform.position;

                if (tempVec3.x == position.x && tempVec3.z == position.z && tempVec3.y >= position.y && tempVec3.y < position.y + 1f)
                {
#if UNITY_2018_3_OR_NEWER
                    YuME_mapEditor.currentTile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(currentLayer.transform.GetChild(i).gameObject)), typeof(GameObject)) as GameObject;
#else
                    YuME_mapEditor.currentTile = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(currentLayer.transform.GetChild(i).gameObject)), typeof(GameObject)) as GameObject;
#endif

                    float pickRotation  = 0;
                    float pickRotationX = 0;

                    Transform pickTileTransform = currentLayer.transform.GetChild(i).transform;

                    if (pickTileTransform.eulerAngles.y > 0)
                    {
                        pickRotation = pickTileTransform.eulerAngles.y;
                    }

                    if (pickTileTransform.eulerAngles.x > 0)
                    {
                        pickRotationX = pickTileTransform.eulerAngles.x;
                    }

                    YuME_mapEditor.currentBrushIndex = Array.IndexOf(YuME_mapEditor.currentTileSetObjects, YuME_mapEditor.currentTile);
                    YuME_mapEditor.tileRotation      = pickRotation;
                    YuME_mapEditor.tileRotationX     = pickRotationX;

                    tempVec3    = pickTileTransform.localScale;
                    tempVec3.x /= YuME_mapEditor.globalScale;
                    tempVec3.y /= YuME_mapEditor.globalScale;
                    tempVec3.z /= YuME_mapEditor.globalScale;
                    YuME_mapEditor.tileScale = tempVec3;

                    YuME_brushFunctions.updateBrushTile(pickTileTransform.localScale);
                    YuME_mapEditor.currentBrushType = YuME_mapEditor.brushTypes.standardBrush;
                    YuME_mapEditor.selectedTool     = YuME_mapEditor.toolIcons.brushTool;

                    return;
                }
            }
        }
    }
Пример #5
0
    static void drawCustomBrushButtons(int index)
    {
        Texture2D  previewImage  = AssetPreview.GetAssetPreview(currentCustomBrushes[index]);
        GUIContent buttonContent = new GUIContent(previewImage);

        bool isActive = false;

        if (currentTile.name == currentCustomBrushes[index].name)
        {
            isActive = true;
        }

        EditorGUILayout.BeginVertical();

        bool isToggleDown = GUILayout.Toggle(isActive, buttonContent, GUI.skin.button);

        if (isToggleDown == true && isActive == false)
        {
            currentTile      = currentCustomBrushes[index];
            currentBrushType = brushTypes.customBrush;
            tileRotation     = 0f;
            YuME_brushFunctions.updateBrushTile();
            selectedTool = toolIcons.brushTool;
        }

        if (GUILayout.Button("Delete Brush"))
        {
            if (EditorUtility.DisplayDialog("Delete Custom Brush?", "Are you sure you want to delete the custom brush prefab from the project", "Delete", "No"))
            {
                string destinationPath = availableTileSets[currentTileSetIndex].customBrushDestinationFolder + "/" + currentCustomBrushes[index].name + ".prefab";
                AssetDatabase.DeleteAsset(destinationPath);
                loadCustomBrushes();
            }
        }

        EditorGUILayout.EndVertical();
    }
Пример #6
0
    public static void checkMouseShortcuts(Event mouseEvent)
    {
        if (mouseEvent.type == EventType.scrollWheel && mouseEvent.shift && !mouseEvent.control && !mouseEvent.alt)
        {
            mouseEvent.Use();

            if (Event.current.delta.y >= 0f)
            {
                YuME_mapEditor.gridHeight++;
            }
            else
            {
                YuME_mapEditor.gridHeight--;
            }
        }
        if (mouseEvent.type == EventType.scrollWheel && mouseEvent.shift && mouseEvent.alt && !mouseEvent.control)
        {
            mouseEvent.Use();

            if (Event.current.delta.y >= 0f)
            {
                YuME_mapEditor.gridHeight += 0.25f;
            }
            else
            {
                YuME_mapEditor.gridHeight -= 0.25f;
            }
        }
        else if (mouseEvent.type == EventType.scrollWheel && mouseEvent.control && mouseEvent.alt && YuME_mapEditor.selectedTool == YuME_mapEditor.toolIcons.brushTool)
        {
            mouseEvent.Use();

            if (Event.current.delta.y >= 0f)
            {
                YuME_mapEditor.tileRotation += 90f;
            }
            else
            {
                YuME_mapEditor.tileRotation -= 90f;
            }
        }
        else if (mouseEvent.type == EventType.scrollWheel && mouseEvent.control && mouseEvent.shift == true && YuME_mapEditor.selectedTool == YuME_mapEditor.toolIcons.brushTool)
        {
            mouseEvent.Use();

            YuME_mapEditor.currentBrushType = YuME_mapEditor.brushTypes.standardBrush;

            if (Event.current.delta.y > 0f)
            {
                YuME_mapEditor.currentBrushIndex++;

                if (YuME_mapEditor.currentBrushIndex >= YuME_mapEditor.currentTileSetObjects.Length)
                {
                    YuME_mapEditor.currentBrushIndex = YuME_mapEditor.currentTileSetObjects.Length - 1;
                }

                YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(0f, YuME_mapEditor.tileRotation, 0f);
                YuME_brushFunctions.updateBrushTile();
            }
            else
            {
                YuME_mapEditor.currentBrushIndex--;

                if (YuME_mapEditor.currentBrushIndex < 0)
                {
                    YuME_mapEditor.currentBrushIndex = 0;
                }

                YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(0f, YuME_mapEditor.tileRotation, 0f);
                YuME_brushFunctions.updateBrushTile();
            }
        }
    }
Пример #7
0
    public static void checkMouseShortcuts(Event mouseEvent)
    {
        if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.shift && !mouseEvent.control && !mouseEvent.alt)
        {
            mouseEvent.Use();
            if (!YuME_mapEditor.editorPreferences.invertMouseWheel)
            {
                if (!YuME_mapEditor.editorPreferences.twoPointFiveDMode)
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        YuME_mapEditor.gridHeight += YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        YuME_mapEditor.gridHeight -= YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                }
                else
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        YuME_mapEditor.gridHeight -= YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        YuME_mapEditor.gridHeight += YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                }
            }
            else
            {
                if (!YuME_mapEditor.editorPreferences.twoPointFiveDMode)
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        YuME_mapEditor.gridHeight -= YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        YuME_mapEditor.gridHeight += YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                }
                else
                {
                    if (Event.current.delta.y - Event.current.delta.x >= 0f)
                    {
                        YuME_mapEditor.gridHeight += YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                    else
                    {
                        YuME_mapEditor.gridHeight -= YuME_mapEditor.globalScale * YuME_mapEditor.editorPreferences.gridLayerHeightScaler;
                    }
                }
            }
        }
        if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.shift && mouseEvent.alt && !mouseEvent.control)
        {
            mouseEvent.Use();

            if (!YuME_mapEditor.editorPreferences.invertMouseWheel)
            {
                if (Event.current.delta.y - Event.current.delta.x >= 0f)
                {
                    YuME_mapEditor.gridHeight += (YuME_mapEditor.globalScale * 0.25f);
                }
                else
                {
                    YuME_mapEditor.gridHeight -= (YuME_mapEditor.globalScale * 0.25f);
                }
            }
            else
            {
                if (Event.current.delta.y - Event.current.delta.x >= 0f)
                {
                    YuME_mapEditor.gridHeight -= (YuME_mapEditor.globalScale * 0.25f);
                }
                else
                {
                    YuME_mapEditor.gridHeight += (YuME_mapEditor.globalScale * 0.25f);
                }
            }
        }
        else if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.control && mouseEvent.alt && YuME_mapEditor.selectedTool == YuME_mapEditor.toolIcons.brushTool)
        {
            mouseEvent.Use();

            if (Event.current.delta.y - Event.current.delta.x >= 0f)
            {
                YuME_mapEditor.tileRotation += 90f;
            }
            else
            {
                YuME_mapEditor.tileRotation -= 90f;
            }
        }
        else if (mouseEvent.type == EventType.ScrollWheel && mouseEvent.control && mouseEvent.shift == true && YuME_mapEditor.selectedTool == YuME_mapEditor.toolIcons.brushTool)
        {
            mouseEvent.Use();

            YuME_mapEditor.currentBrushType = YuME_mapEditor.brushTypes.standardBrush;

            if (!YuME_mapEditor.editorPreferences.invertMouseWheel)
            {
                if (Event.current.delta.y - Event.current.delta.x > 0f)
                {
                    YuME_mapEditor.currentBrushIndex++;

                    if (YuME_mapEditor.currentBrushIndex >= YuME_mapEditor.currentTileSetObjects.Length)
                    {
                        YuME_mapEditor.currentBrushIndex = YuME_mapEditor.currentTileSetObjects.Length - 1;
                    }

                    YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                    YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(YuME_mapEditor.tileRotationX, YuME_mapEditor.tileRotation, 0f);
                    YuME_brushFunctions.updateBrushTile();
                }
                else
                {
                    YuME_mapEditor.currentBrushIndex--;

                    if (YuME_mapEditor.currentBrushIndex < 0)
                    {
                        YuME_mapEditor.currentBrushIndex = 0;
                    }

                    YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                    YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(YuME_mapEditor.tileRotationX, YuME_mapEditor.tileRotation, 0f);
                    YuME_brushFunctions.updateBrushTile();
                }
            }
            else
            {
                if (Event.current.delta.y - Event.current.delta.x < 0f)
                {
                    YuME_mapEditor.currentBrushIndex++;

                    if (YuME_mapEditor.currentBrushIndex >= YuME_mapEditor.currentTileSetObjects.Length)
                    {
                        YuME_mapEditor.currentBrushIndex = YuME_mapEditor.currentTileSetObjects.Length - 1;
                    }

                    YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                    YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(YuME_mapEditor.tileRotationX, YuME_mapEditor.tileRotation, 0f);
                    YuME_brushFunctions.updateBrushTile();
                }
                else
                {
                    YuME_mapEditor.currentBrushIndex--;

                    if (YuME_mapEditor.currentBrushIndex < 0)
                    {
                        YuME_mapEditor.currentBrushIndex = 0;
                    }

                    YuME_mapEditor.currentTile = YuME_mapEditor.currentTileSetObjects[YuME_mapEditor.currentBrushIndex];
                    YuME_mapEditor.currentTile.transform.eulerAngles = new Vector3(YuME_mapEditor.tileRotationX, YuME_mapEditor.tileRotation, 0f);
                    YuME_brushFunctions.updateBrushTile();
                }
            }
        }
    }