void OnEnable() { seed = serializedObject.FindProperty("seed"); scriptableLayers = serializedObject.FindProperty("scriptableLayers"); layerBase = (NetworkScriptableTileLayer)target; if (layerBase.scriptableLayers == null || layerBase.scriptableLayers.Length == 0) { layerBase.scriptableLayers = new ScriptableTileLayer[1]; layerBase.scriptableLayers[0] = new ScriptableTileLayer(); layerBase.scriptableLayers[0].name = "Layer 0"; TileInfo tileInfo = layerBase.GetComponent <TileInfo>(); layerBase.scriptableLayers[0].layers = new TileInfo[1] { tileInfo }; layerBase.scriptableLayers[0].update3DWalls = tileInfo.update3DWalls; layerBase.scriptableLayers[0].update2DColliders = tileInfo.update2DColliders; layerBase.chunkWidth = tileInfo.mapWidth; layerBase.chunkHeight = tileInfo.mapHeight; } ResetSizeAndOffset(); ResetChunkSize(); if (selectedLayer >= layerBase.scriptableLayers.Length) { selectedLayer = 0; } TilesetEditor.ChangeTileLayer(layerBase.GetComponent <TileInfo>()); }
public static void SceneGUI(NetworkScriptableTileLayer layerBase) { if (layerBase.scriptableLayers == null || layerBase.scriptableLayers.Length == 0) { return; } if (selectedLayer >= layerBase.scriptableLayers.Length) { selectedLayer = 0; } Handles.BeginGUI(); GUILayout.BeginHorizontal("box", GUILayout.Width(100)); if (GUILayout.Button("<")) { selectedLayer--; if (selectedLayer < 0) { selectedLayer = layerBase.scriptableLayers.Length - 1; } if (layerBase.scriptableLayers[selectedLayer].layers.Length > 0) { TilesetEditor.ChangeTileLayer(layerBase.scriptableLayers[selectedLayer].layers[0]); } } GUILayout.Label(layerBase.scriptableLayers[selectedLayer].name); if (GUILayout.Button(">")) { selectedLayer++; if (selectedLayer >= layerBase.scriptableLayers.Length) { selectedLayer = 0; } if (layerBase.scriptableLayers[selectedLayer].layers.Length > 0) { TilesetEditor.ChangeTileLayer(layerBase.scriptableLayers[selectedLayer].layers[0]); } } GUILayout.EndHorizontal(); Handles.EndGUI(); }