92 lines
1.8 KiB
C#
92 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Mtree
|
|
{
|
|
public class TreeFunctionAsset : ScriptableObject
|
|
{
|
|
public int seed;
|
|
|
|
public static int positionOffset = 30;
|
|
|
|
public static int height = 37;
|
|
|
|
public static int width = 200;
|
|
|
|
public static int margin = -3;
|
|
|
|
public static int deleteButtonSize = 18;
|
|
|
|
public static GUIStyle nodeStyle;
|
|
|
|
public static GUIStyle selectedNodeStyle;
|
|
|
|
public static GUIStyle deleteButtonStyle;
|
|
|
|
public int id;
|
|
|
|
public TreeFunctionAsset parent;
|
|
|
|
public List<TreeFunctionAsset> chiildren;
|
|
|
|
public bool enabled = true;
|
|
|
|
public bool showDeleteButton = true;
|
|
|
|
public Rect rect;
|
|
|
|
public Rect deleteRect;
|
|
|
|
public virtual void Init(TreeFunctionAsset parent, bool preserveSettings = false)
|
|
{
|
|
this.parent = parent;
|
|
if (parent != null)
|
|
{
|
|
parent.chiildren.Add(this);
|
|
}
|
|
chiildren = new List<TreeFunctionAsset>();
|
|
id = Guid.NewGuid().GetHashCode();
|
|
}
|
|
|
|
public virtual void Execute(MTree tree)
|
|
{
|
|
if (enabled && parent != null && parent.enabled)
|
|
{
|
|
}
|
|
}
|
|
|
|
public void DrawFunction(bool isSelected = false, bool deleteButton = true)
|
|
{
|
|
}
|
|
|
|
public void UpdateRectRec(ref int heightIndex, int marginIndex)
|
|
{
|
|
float num = marginIndex * positionOffset;
|
|
float num2 = heightIndex * (height + margin);
|
|
rect.Set(num, num2, width, height);
|
|
if (showDeleteButton)
|
|
{
|
|
deleteRect.Set(num + (float)width - 12f - (float)deleteButtonSize, num2 + (float)((height - deleteButtonSize) / 2), deleteButtonSize, deleteButtonSize);
|
|
}
|
|
else
|
|
{
|
|
deleteRect.Set(0f, 0f, 0f, 0f);
|
|
}
|
|
foreach (TreeFunctionAsset item in chiildren)
|
|
{
|
|
heightIndex++;
|
|
item.UpdateRectRec(ref heightIndex, marginIndex + 1);
|
|
}
|
|
}
|
|
|
|
public virtual void DrawProperties()
|
|
{
|
|
}
|
|
|
|
private static void UpdateStyle()
|
|
{
|
|
}
|
|
}
|
|
}
|