mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-21 18:15:39 -05:00
bindCell
This commit is contained in:
@@ -51,6 +51,8 @@ namespace RotateParticle.Components
|
||||
{
|
||||
var root = new VisualElement();
|
||||
|
||||
root.TrackSerializedObjectValue(serializedObject, OnValueChanged);
|
||||
|
||||
root.Bind(serializedObject);
|
||||
|
||||
{
|
||||
@@ -61,25 +63,46 @@ namespace RotateParticle.Components
|
||||
root.Add(new PropertyField { bindingPath = nameof(WarpRoot.BaseSettings) });
|
||||
root.Add(new PropertyField { bindingPath = nameof(WarpRoot.Center) });
|
||||
|
||||
root.Add(new PropertyField { bindingPath = nameof(WarpRoot.Particles) });
|
||||
root.Add(new PropertyField { bindingPath = "m_particles" });
|
||||
|
||||
{
|
||||
m_treeview = new MultiColumnTreeView();
|
||||
m_treeview.columns.Add(new Column
|
||||
{
|
||||
title = "Transform",
|
||||
width = 160,
|
||||
makeCell = () => new ObjectField(),
|
||||
makeCell = () => new ObjectField
|
||||
{
|
||||
},
|
||||
bindCell = (v, i) =>
|
||||
{
|
||||
v.SetEnabled(false);
|
||||
(v as ObjectField).value = m_target.GetParticle(i).Transform;
|
||||
// var prop = serializedObject.FindProperty($"m_particles.Array.data[{i}].Transform");
|
||||
// Debug.Log($"{i} => {prop}");
|
||||
if (v is ObjectField prop)
|
||||
{
|
||||
// prop.bindingPath = $"m_particles.Array.data[{i}].Transform";
|
||||
prop.BindProperty(serializedObject.FindProperty($"m_particles.Array.data[{i}].Transform"));
|
||||
}
|
||||
},
|
||||
});
|
||||
m_treeview.columns.Add(new Column
|
||||
{
|
||||
title = "Mode",
|
||||
width = 60,
|
||||
makeCell = () => new EnumField(default(WarpRoot.ParticleMode)),
|
||||
// makeCell = () => new EnumField(default(WarpRoot.ParticleMode)),
|
||||
makeCell = () => new EnumField
|
||||
{
|
||||
// bindingPath = $"m_particles.Array.data[0].Mode",
|
||||
},
|
||||
bindCell = (v, i) =>
|
||||
{
|
||||
if (v is EnumField prop)
|
||||
{
|
||||
prop.bindingPath = $"m_particles.Array.data[{i}].Mode";
|
||||
prop.Bind(serializedObject);
|
||||
}
|
||||
},
|
||||
});
|
||||
m_treeview.columns.Add(new Column
|
||||
{
|
||||
@@ -110,6 +133,14 @@ namespace RotateParticle.Components
|
||||
title = "radius",
|
||||
width = 20,
|
||||
makeCell = () => new FloatField(),
|
||||
bindCell = (v, i) =>
|
||||
{
|
||||
if (v is FloatField prop)
|
||||
{
|
||||
prop.BindProperty(serializedObject.FindProperty($"m_particles.Array.data[{i}].Settings.radius"));
|
||||
prop.SetEnabled(m_target.Particles[i].Mode == WarpRoot.ParticleMode.Custom);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
m_treeview.autoExpand = true;
|
||||
@@ -122,8 +153,23 @@ namespace RotateParticle.Components
|
||||
return root;
|
||||
}
|
||||
|
||||
private void OnValueChanged(SerializedObject so)
|
||||
{
|
||||
Debug.Log("Name changed: " + so.targetObject.name);
|
||||
// var nameProperty = so.FindProperty("m_Name");
|
||||
|
||||
// if (nameProperty.stringValue.Contains(" "))
|
||||
// _textField.style.backgroundColor = Color.red;
|
||||
// else
|
||||
// _textField.style.backgroundColor = StyleKeyword.Null;
|
||||
m_treeview.RefreshItems();
|
||||
// m_treeview.SetRootItems(m_target.m_rootitems);
|
||||
Repaint();
|
||||
}
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
HandleUtility.Repaint();
|
||||
if (m_treeview == null)
|
||||
{
|
||||
return;
|
||||
@@ -137,6 +183,7 @@ namespace RotateParticle.Components
|
||||
|
||||
if (item is WarpRoot.Particle p)
|
||||
{
|
||||
p = m_target.GetParticleFromTransform(p.Transform);
|
||||
var t = p.Transform;
|
||||
Handles.color = Color.green;
|
||||
Handles.SphereHandleCap(t.GetInstanceID(), t.position, t.rotation, p.Settings.radius * 2, EventType.Repaint);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace RotateParticle.Components
|
||||
/// <summary>
|
||||
/// Use specific settings
|
||||
/// </summary>
|
||||
Override,
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// no animation
|
||||
/// </summary>
|
||||
@@ -63,7 +63,7 @@ namespace RotateParticle.Components
|
||||
}
|
||||
|
||||
public Particle(Transform t, BlittableJointMutable settings)
|
||||
: this(t, ParticleMode.Override, settings)
|
||||
: this(t, ParticleMode.Custom, settings)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace RotateParticle.Components
|
||||
public List<TreeViewItemData<Particle>> MakeTree(int id)
|
||||
{
|
||||
List<TreeViewItemData<Particle>> items = new();
|
||||
foreach (Transform child_transform in id==-1 ? transform : m_particles[id].Transform)
|
||||
foreach (Transform child_transform in id == -1 ? transform : m_particles[id].Transform)
|
||||
{
|
||||
var child_id = m_map[child_transform];
|
||||
var item = (child_transform.childCount > 0)
|
||||
@@ -135,11 +135,23 @@ namespace RotateParticle.Components
|
||||
return items;
|
||||
}
|
||||
|
||||
public Particle GetParticle(int id)
|
||||
public Particle GetParticleFromId(int id)
|
||||
{
|
||||
return m_particles[id];
|
||||
}
|
||||
|
||||
public Particle GetParticleFromTransform(Transform t)
|
||||
{
|
||||
foreach (var p in m_particles)
|
||||
{
|
||||
if (p.Transform == t)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
public void UseBaseSettings(Transform t)
|
||||
{
|
||||
if (t == null) return;
|
||||
@@ -164,7 +176,7 @@ namespace RotateParticle.Components
|
||||
var p = m_particles[i];
|
||||
if (p.Transform == t)
|
||||
{
|
||||
p.Mode = ParticleMode.Override;
|
||||
p.Mode = ParticleMode.Custom;
|
||||
p.Settings = settings;
|
||||
m_particles[i] = p;
|
||||
break;
|
||||
@@ -172,12 +184,6 @@ namespace RotateParticle.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// internal List<Warp> ToList()
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
public void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.DrawSphere(transform.position, BaseSettings.radius);
|
||||
@@ -199,8 +205,7 @@ namespace RotateParticle.Components
|
||||
|
||||
bool TryGetClosestParent(Transform t, out Transform parent)
|
||||
{
|
||||
var current = t.parent;
|
||||
while (current != null)
|
||||
for (var current = t.parent; current != null; current = current.parent)
|
||||
{
|
||||
if (current == transform)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user