private void AssignValues() { brushScales = new int[] { 1, 3, 5, 7, 9, 11, 13, 15 }; brushTiles = new string[brushScales.Length]; for (int i = 0; i < brushScales.Length; i++) { brushTiles[i] = Mathf.RoundToInt(Mathf.Pow(brushScales[i], 2)).ToString(); } enableDesigner = serializedObject.FindProperty("enableDesigner"); tileScale = serializedObject.FindProperty("tileScale"); yOffset = serializedObject.FindProperty("yOffset"); brushIndex = serializedObject.FindProperty("brushIndex"); alignY = serializedObject.FindProperty("alignY"); tagsToIgnore = serializedObject.FindProperty("tagsToIgnore"); layersToIgnore = serializedObject.FindProperty("layersToIgnore"); disableMeshRenderersAtStart = serializedObject.FindProperty("disableMeshRenderersAtStart"); storage = serializedObject.FindProperty("storage"); CreateSceneAssets(); meshPainter = new MeshPainter(); meshPainter.Enable(this); }
private void ReplaceTiles() { meshPainter.ClearMesh(); meshPainter.Enable(); // This line is needed because TilePositionsProperty keeps it's values when using UNDO tilePositionsProperty = new SerializedObject(gridBase.storage).FindProperty("tilePositions"); SerializedProperty tempPositions = TilePositionsProperty.Copy(); // copy so we don't iterate the original if (tempPositions.isArray) { int arrayLength = 0; tempPositions.Next(true); // skip generic field tempPositions.Next(true); // advance to array size field // Get the array size arrayLength = tempPositions.intValue; tempPositions.Next(true); // advance to first array index // Write values to list List <Vector3> values = new List <Vector3>(arrayLength); int lastIndex = arrayLength - 1; for (int i = 0; i < arrayLength; i++) { values.Add(tempPositions.vector3Value); // copy the value to the list if (i < lastIndex) { tempPositions.Next(false); // advance without drilling into children } } // iterate over the list displaying the contents for (int i = 0; i < values.Count; i++) { meshPainter.DrawTile(values[i]); } AssetDatabase.SaveAssets(); } }