First commit

This commit is contained in:
Misaki
2024-11-02 17:58:52 +09:00
commit e645a5327b
153 changed files with 3729 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using Unity.Properties;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using Object = UnityEngine.Object;
namespace Misaki.GraphView.Editor.Editor.Helpers
{
public class PropertyFieldHelper
{
private static readonly Dictionary<Type, Func<string, VisualElement>> _propertyFieldCreators = new ()
{
{typeof(float), (s) => new FloatField(s)},
{typeof(int), (s) => new IntegerField(s)},
{typeof(uint), (s) => new IntegerField(s)},
{typeof(long), (s) => new LongField(s)},
{typeof(bool), (s) => new Toggle(s)},
{typeof(string), (s) => new TextField(s)}
};
public static VisualElement CreatePropertyField(Type propertyType, object dataSource, PropertyPath bindingPath, string label)
{
if (_propertyFieldCreators.TryGetValue(propertyType, out var creator))
{
var propertyField = creator.Invoke(label);
propertyField.dataSource = dataSource;
propertyField.dataSourcePath = bindingPath;
return propertyField;
}
return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0cc84c66a467437f9dfbc835f2112f15
timeCreated: 1730381553

View File

@@ -0,0 +1,51 @@
using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace Misaki.GraphView.Editor
{
public enum DockingPosition
{
Left,
Right,
Top,
Bottom
}
internal static class WindowDockingLayout
{
public static void DockToParent(this VisualElement ve, Rect parentLayout, DockingPosition dockingPosition, bool changeSize)
{
var layout = ve.layout;
switch (dockingPosition)
{
case DockingPosition.Left:
ve.style.left = parentLayout.x;
ve.style.top = parentLayout.y;
ve.style.width = layout.width;
ve.style.height = changeSize ? parentLayout.height : layout.height;
break;
case DockingPosition.Right:
ve.style.left = parentLayout.x + parentLayout.width - layout.width;
ve.style.top = parentLayout.y;
ve.style.width = layout.width;
ve.style.height = changeSize ? parentLayout.height : layout.height;
break;
case DockingPosition.Top:
ve.style.left = parentLayout.x;
ve.style.top = parentLayout.y;
ve.style.width = changeSize ? parentLayout.width : layout.width;
ve.style.height = layout.height;
break;
case DockingPosition.Bottom:
ve.style.left = parentLayout.x;
ve.style.top = parentLayout.y + parentLayout.height - layout.height;
ve.style.width = changeSize ? parentLayout.width : layout.width;
ve.style.height = layout.height;
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 20da7f7c16bd49399699522258602d5e
timeCreated: 1730390740