-
Notifications
You must be signed in to change notification settings - Fork 1
[Manual] Simple Path Generator
Unity Flow Visualizer's simple version
To be updated later
ํ๊ตญ์ด ์ค๋ช ์ ์๋์ ์์ต๋๋ค.
- Expresses only the shortest straight line path by receiving two point (Vector3 or Transform)
- Visualizer that can display the flow rate passing through the path
in Unity Scene, You should instantiate Assets\UnityFlowVisualizer\Prefabs\SimplePath\SimplePathGenerator prefabs (You only need one in the scene)
To use the Simple Path Visualizer, you must use the UnityFlowVisualizer namespace in your script.
using UnityFlowVisualizer;In order to use the Simple Path Visualizer, you need to get an instance of SimplePathGenerator.
SimplePathGenerator simplePath = SimplePathGenerator.Instance;At this time, if step 2 is not performed, SimplePathGenerator.Instance is null.
You can create a path connecting two points through the public GameObject InstantiatePath(...) function of SimplePathGenerator.
public GameObject InstantiatePath(...) is overloaded with the following 4 types.
- public GameObject InstantiatePath(Transform Start, Transform End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Vector3 Start, Vector3 End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Transform Parent, Transform Start, Transform End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Transform Parent, Vector3 Start, Vector3 End, Color PathColor, float Thickness = 1f);
A description of the parameters is as follows.
| Parameter | Description |
|---|---|
| Start | The starting point of the Path (For Vector3, it must be World coordinates of the starting point) |
| End | End point of Path (For Vector3, it must be World coordinates of the starting point) |
| Parent | Path can be set as a child of that object |
| Color | The color of the path. Alpha value can be applyed |
| Thickness | The thickness of the path. Default 1 |
Through the public GameObject Shooting(...) function of SimplePathGenerator, you can visualize the flow rate that flows through the path.
public GameObject Shooting(...) has the following three overloads.
- public GameObject Shooting(SimplePath path, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed = 0.2f);
- public GameObject Shooting(Transform start, Transform end, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed =0.2f);
- public GameObject Shooting(Vector3 start, Vector3 end, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed = 0.2f);
A description of the parameters is as follows.
| Parameter | Description |
|---|---|
| Start | The starting point of the Path (For Vector3, it must be World coordinates of the starting point) |
| End | End point of Path (For Vector3, it must be World coordinates of the starting point) |
| path | Path to be expressed. |
| type | Type of flow particle. Default FLOW_BLUE |
| speed | flow rate. Default 0.2 |
Here, SHOT_TYPE is an enum declared in SimplePathGenerator and is as follows.
public enum SHOT_TYPE {
FLOW_RED, FLOW_GREEN, FLOW_BLUE,
GAS_RED, GAS_GREEN, GAS_BLUE,
ELEC_RED, ELEC_GREEN, ELEC_BLUE
}You can delete the created path through the public void DeletePath(SimplePath path) function of SimplePathGenerator.
You can remove all generated paths through the public void ClearPath() function of SimplePathGenerator.
This is useful when you want to redraw the path.
Here is a demo of SimplePathDemo.unity located in Assets\UnityFlowVisualizer\Demo.

The following test code was used.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityFlowVisualizer; // UnityFlowVisualizer ๋ค์ ์คํ์ด์ค ์ฌ์ฉ
public class SimplePathTest : MonoBehaviour
{
public Transform StartTr;
public Transform EndTr;
public Color PathColor;
// Start is called before the first frame update
void Start()
{
// Draw path
SimplePathGenerator.Instance.InstantiatePath(StartTr, EndTr, PathColor, 1f);
// Visualize flow
StartCoroutine(Shooting());
}
// Update is called once per frame
IEnumerator Shooting()
{
while(true) {
// Fires FLOW_BLUE at a speed of 0.2 every 0.7 seconds
SimplePathGenerator.Instance.Shooting(StartTr, EndTr);
yield return new WaitForSeconds(0.35f);
}
}
}Unity Flow Visualizer์ ๊ฐ๋จํ ๋ฒ์
์ถํ ๋ ์ ๋ฐ์ดํธ ์์
- ๋ ์ขํ(Vector3๋๋ Transform)์ ์ ๋ ฅ๋ฐ์ ์ต๋จ๊ฑฐ๋ฆฌ ์ง์ Path๋ง์ ํํ
- Path๋ฅผ ์ง๋๊ฐ๋ ์ ๋์ ํ์ ํ ์ ์๋ Visualize
Unity Scene์์, Assets\UnityFlowVisualizer\Prefabs\SimplePath\SimplePathGeneratorํ๋ฆฌํน์ ์ธ์คํด์คํ ํด์ผํจ (Scene์ ํ๋๋ง ์์ผ๋ฉด ๋จ)
Simple Path Visualizer๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์, ์คํฌ๋ฆฝํธ์์ UnityFlowVisualizer ๋ค์์คํ์ด์ค๋ฅผ ์ฌ์ฉํด์ผํจ
using UnityFlowVisualizer;Simple Path Visualizer๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์, SimplePathGenerator ์ธ์คํด์ค๋ฅผ ๊ฐ์ ธ์์ผํจ
SimplePathGenerator simplePath = SimplePathGenerator.Instance;์ด๋, 2๋ฅผ ์งํํ์ง ์์์ผ๋ฉด, SimplePathGenerator.Instance๋ null์
SimplePathGenerator์ public GameObject InstantiatePath(...) ํจ์๋ฅผ ํตํด ๋ ์ ์ ์๋ Path๋ฅผ ๋ง๋ค ์ ์์
public GameObject InstantiatePath(...)๋ ๋ค์ 4๊ฐ์ง๋ก ์ค๋ฒ๋ก๋ฉ๋์ด ์๋ค.
- public GameObject InstantiatePath(Transform Start, Transform End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Vector3 Start, Vector3 End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Transform Parent, Transform Start, Transform End, Color PathColor, float Thickness = 1f);
- public GameObject InstantiatePath(Transform Parent, Vector3 Start, Vector3 End, Color PathColor, float Thickness = 1f);
ํ๋ผ๋ฏธํฐ์ ๋ํ ์ค๋ช ์ ์๋์ ๊ฐ๋ค.
| ํ๋ผ๋ฏธํฐ | ์ค๋ช |
|---|---|
| Start | Path์ ์์ ์ง์ (Vector3์ธ ๊ฒฝ์ฐ, ์์ ์ง์ ์ World์ขํ์ฌ์ผ ํจ) |
| End | Path์ ๋ ์ง์ (Vector3์ธ ๊ฒฝ์ฐ, ์์ ์ง์ ์ World์ขํ์ฌ์ผ ํจ) |
| Parent | ํด๋น ์ค๋ธ์ ํธ์ ์์์ผ๋ก Path๋ฅผ ์ค์ ํ ์ ์์ |
| Color | Path์ ์์. Alpha๊ฐ์ ๋ฃ์ ์ ์์ |
| Thickness | Path์ ๋๊ป. ๊ธฐ๋ณธ๊ฐ 1 |
SimplePathGenerator์ public GameObject Shooting(...) ํจ์๋ฅผ ํตํด Path๋ฅผ ํ๋ฅด๋ ์ ๋์ ์๊ฐํ ํ ์ ์๋ค.
public GameObject Shooting(...)๋ ๋ค์ 3๊ฐ์ง๋ก ์ค๋ฒ๋ก๋ฉ๋์ด ์๋ค.
- public GameObject Shooting(SimplePath path, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed = 0.2f);
- public GameObject Shooting(Transform start, Transform end, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed =0.2f);
- public GameObject Shooting(Vector3 start, Vector3 end, SHOT_TYPE type = SHOT_TYPE.FLOW_BLUE, float speed = 0.2f);
ํ๋ผ๋ฏธํฐ์ ๋ํ ์ค๋ช ์ ์๋์ ๊ฐ๋ค.
| ํ๋ผ๋ฏธํฐ | ์ค๋ช |
|---|---|
| Start | Path์ ์์ ์ง์ (Vector3์ธ ๊ฒฝ์ฐ, ์์ ์ง์ ์ World์ขํ์ฌ์ผ ํจ) |
| End | Path์ ๋ ์ง์ (Vector3์ธ ๊ฒฝ์ฐ, ์์ ์ง์ ์ World์ขํ์ฌ์ผ ํจ) |
| path | ํํํ๊ณ ์ ํ๋ Path. |
| type | ์ ๋ Particle์ ์ข ๋ฅ. ๊ธฐ๋ณธ๊ฐ FLOW_BLUE |
| speed | ์ ๋์ ์๋. ๊ธฐ๋ณธ๊ฐ 0.2 |
์ฌ๊ธฐ์ SHOT_TYPE์ SimplePathGenerator์ ์ ์ธ๋ enum์ผ๋ก ๋ค์๊ณผ ๊ฐ๋ค.
public enum SHOT_TYPE {
FLOW_RED, FLOW_GREEN, FLOW_BLUE,
GAS_RED, GAS_GREEN, GAS_BLUE,
ELEC_RED, ELEC_GREEN, ELEC_BLUE
}SimplePathGenerator์ public void DeletePath(SimplePath path) ํจ์๋ฅผ ํตํด ์์ฑ๋ Path๋ฅผ ์ ๊ฑฐ ํ ์ ์๋ค.
SimplePathGenerator์ public void ClearPath() ํจ์๋ฅผ ํตํด ์์ฑ๋ ๋ชจ๋ Path๋ฅผ ์ ๊ฑฐ ํ ์ ์๋ค.
Path๋ฅผ ๋ค์ ๊ทธ๋ฆฌ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ฉด ์ข๋ค.
๋ค์์ Assets\UnityFlowVisualizer\Demo์ ์๋ SimplePathDemo.unity ๋ฐ๋ชจ์ด๋ค.

์๋์ ๊ฐ์ ํ ์คํธ ์ฝ๋๋ฅผ ์ฌ์ฉํ์๋ค.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityFlowVisualizer; // UnityFlowVisualizer ๋ค์ ์คํ์ด์ค ์ฌ์ฉ
public class SimplePathTest : MonoBehaviour
{
public Transform StartTr;
public Transform EndTr;
public Color PathColor;
// Start is called before the first frame update
void Start()
{
// Path ๊ทธ๋ฆฌ๊ธฐ
SimplePathGenerator.Instance.InstantiatePath(StartTr, EndTr, PathColor, 1f);
// Flow ์๊ฐํ
StartCoroutine(Shooting());
}
// Update is called once per frame
IEnumerator Shooting()
{
while(true) {
// 0.7์ด๋ง๋ค FLOW_BLUE๋ฅผ ์๋ 0.2๋ก ๋ฐ์ฌ
SimplePathGenerator.Instance.Shooting(StartTr, EndTr);
yield return new WaitForSeconds(0.35f);
}
}
}