Reliable output vector draw line
This commit is contained in:
parent
f2d20dd462
commit
14436cbfba
@ -102,6 +102,25 @@ public class ClusterInspector : Editor {
|
|||||||
// RegisterCallback<MouseDownEvent>(OnMouseDown);
|
// RegisterCallback<MouseDownEvent>(OnMouseDown);
|
||||||
// RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
// RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
||||||
// RegisterCallback<MouseUpEvent>(OnMouseUp);
|
// RegisterCallback<MouseUpEvent>(OnMouseUp);
|
||||||
|
|
||||||
|
// Subscribe when added to panel (editor UI ready)
|
||||||
|
RegisterCallback<AttachToPanelEvent>(evt => Subscribe());
|
||||||
|
RegisterCallback<DetachFromPanelEvent>(evt => Unsubscribe());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool subscribed = false;
|
||||||
|
void Subscribe() {
|
||||||
|
if (subscribed) return;
|
||||||
|
SceneView.duringSceneGui += OnSceneGUI;
|
||||||
|
subscribed = true;
|
||||||
|
SceneView.RepaintAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unsubscribe() {
|
||||||
|
if (!subscribed) return;
|
||||||
|
SceneView.duringSceneGui -= OnSceneGUI;
|
||||||
|
subscribed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetGraph(GameObject gameObject, Cluster brain, INucleus nucleus, VisualElement inspectorContainer) {
|
public void SetGraph(GameObject gameObject, Cluster brain, INucleus nucleus, VisualElement inspectorContainer) {
|
||||||
@ -542,15 +561,25 @@ public class ClusterInspector : Editor {
|
|||||||
DeleteNeuron(this.currentNucleus);
|
DeleteNeuron(this.currentNucleus);
|
||||||
|
|
||||||
|
|
||||||
if (this.gameObject != null) {
|
// if (this.gameObject != null) {
|
||||||
Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
// Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
||||||
Debug.DrawRay(this.gameObject.transform.position, worldVector, Color.yellow);
|
// //Debug.DrawRay(this.gameObject.transform.position, worldVector, Color.yellow);
|
||||||
}
|
// Handles.color = Color.yellow;
|
||||||
|
// Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector);
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
inspectorContainer.Add(container);
|
inspectorContainer.Add(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnSceneGUI(SceneView sceneView) {
|
||||||
|
if (this.gameObject != null) {
|
||||||
|
Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
||||||
|
Handles.color = Color.yellow;
|
||||||
|
Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void AddInputNeuron(INucleus nucleus) {
|
protected virtual void AddInputNeuron(INucleus nucleus) {
|
||||||
Neuron newNeuroid = new(this.cluster.cluster, "New neuron");
|
Neuron newNeuroid = new(this.cluster.cluster, "New neuron");
|
||||||
newNeuroid.AddReceiver(nucleus);
|
newNeuroid.AddReceiver(nucleus);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user