Create your aquarium in Unity Editor.
The aquarium component is provided using Painter2D, which allows HtmlCanvas-like drawing.
It is developed with reference to https://github.com/le-nn/vscode-vector-aquarium
- Unity 2022.1 or later
- Open Package Manager from Window > Package Manager.
- Click the "+" button > Add package from git URL.
- Enter the following URL:
https://github.com/Garume/UniAquarium.git?path=/Assets/UniAquarium
Press Window > Aquarium
from the toolbar to open the aquarium window.
- When tapped, bait appears and fish will chase and eat it.
- When fish tapped, fish will diffuse and escape.
- Other fish will swim.
- Grouped fish swim in swarm.
- You can make your own fish.
Click anywhere on the window and the bait will appear.
The fish will eat this bait.
Click anywhere on the window to generate a shockwave.
The fish will run away from this shockwave.
You can create Scriptable Objects for custom settings.
UniAquariumSettings from Assets > Create > UniAquarium Settings.
Reload window after making any changes to the settings.
The Aquarium window has a reload function.
3-point reader > Reload
Components extending from VisualElement are available to draw aquariums in addition to windows.
By adding this component to any container, you can easily draw an aquarium.
Let's try drawing the aquarium in the Scene Hierarchy Window.
using System.Reflection;
using UniAquarium.Aquarium;
using UnityEditor;
using UnityEngine.UIElements;
[InitializeOnLoad]
public class HierarchyWindowHook
{
private static VisualElement _rootVisualElement;
static HierarchyWindowHook()
{
EditorApplication.update += Update;
}
private static void Update()
{
if (_rootVisualElement != null) return;
// get SceneHierarchyWindow.
var hierarchyWindowType = typeof(Editor).Assembly.GetType("UnityEditor.SceneHierarchyWindow");
var hierarchyWindow = EditorWindow.GetWindow(hierarchyWindowType);
// get VisualElement using reflection.
if (hierarchyWindow == null) return;
var fieldInfo = hierarchyWindowType.GetField("m_SceneHierarchy",
BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldInfo == null) return;
var sceneHierarchy = fieldInfo.GetValue(hierarchyWindow);
var sceneHierarchyType = sceneHierarchy.GetType();
var visualElementFieldInfo = sceneHierarchyType.GetField("m_EditorWindow",
BindingFlags.NonPublic | BindingFlags.Instance);
if (visualElementFieldInfo == null) return;
var treeView = visualElementFieldInfo.GetValue(sceneHierarchy);
var root = treeView as EditorWindow;
_rootVisualElement = root.rootVisualElement;
// Setting it to false disables clicks and other actions.
var aquariumComponent = new AquariumComponent(false);
_rootVisualElement.Add(aquariumComponent);
aquariumComponent.Enable();
}
}
Write it in any file and save it. Then, look at the Scene Hierarchy Window.
So Nice!