示例#1
0
        private void ReplaceTiles()
        {
            meshPainter.ClearMesh();
            meshPainter.SetOffset();

            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();
            }
        }