A lightweight solution for plotting function graphs in Unity3D using UI components.
- Dynamic point plotting on a 2D graph
- Configurable axis dimensions and step counts
- Support for negative axis values
- TextMeshPro integration for axis labels
- Grid lines for visual reference
- Easy integration via prefab
- Unity 2020.3 LTS or newer
- TextMeshPro package
- UnityEngine.UI.Extensions (included)
- Download the latest release
- Import the package into your Unity project
- Drag
GraphController.prefabfromAssets/theGrahCreator/into your scene
| Parameter | Description |
|---|---|
| Axis Length X/Y | Total length of each axis in units |
| Steps X/Y | Number of divisions on each axis |
| Origin X/Y | Starting coordinate offset |
| Point Prefab | Visual representation of plotted points |
| Line Renderer | UILineRenderer for connecting points |
public GraphCreator graph;
void PlotFunction()
{
for (float x = 0; x <= 10; x += 0.5f)
{
graph.InputX = x;
graph.InputY = Mathf.Sin(x) * 5;
graph.AddPoint();
}
}The GraphCreatorInputController component provides UI bindings:
AddPoint()— plots a point from input fieldsClearGraph()— removes all pointsDeleteLastPoint()— removes the most recent point
Assets/theGrahCreator/
├── Scripts/
│ ├── MathPart/
│ │ └── GraphCreator.cs # Core graph logic
│ ├── GraphCreatorInputController.cs
│ └── CustomParser.cs # Number parsing utility
├── Scenes/
│ └── SampleScene.unity
├── unity-ui-extensions/ # UI Extensions library
└── GraphController.prefab
Standard Configuration:
Negative Axis Values:
| Property | Type | Description |
|---|---|---|
DataPoints |
List<Vector2> |
All plotted coordinates |
PointInstances |
List<GameObject> |
Instantiated point objects |
InputX |
float |
X coordinate for next point |
InputY |
float |
Y coordinate for next point |
| Method | Description |
|---|---|
AddPoint() |
Plots current InputX/InputY |
DeletePoint() |
Removes last plotted point |
DeleteAllPoints() |
Clears the entire graph |
InitializeGraph() |
Rebuilds axis labels |
| Method | Description |
|---|---|
ParseToDouble(string) |
Culture-aware string to double conversion |
MIT License — see LICENSE.md
Легковесное решение для построения графиков функций в Unity3D с использованием UI компонентов.
- Динамическое построение точек на 2D графике
- Настраиваемые размеры осей и количество делений
- Поддержка отрицательных значений осей
- Интеграция с TextMeshPro
- Линии сетки
- Простая интеграция через prefab
- Скачайте последний релиз
- Импортируйте пакет в проект Unity
- Перетащите
GraphController.prefabизAssets/theGrahCreator/в сцену
MIT License — см. LICENSE.md


