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<MouseMoveEvent>(OnMouseMove);
|
||||
// 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) {
|
||||
@ -542,15 +561,25 @@ public class ClusterInspector : Editor {
|
||||
DeleteNeuron(this.currentNucleus);
|
||||
|
||||
|
||||
if (this.gameObject != null) {
|
||||
Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
||||
Debug.DrawRay(this.gameObject.transform.position, worldVector, Color.yellow);
|
||||
}
|
||||
// if (this.gameObject != null) {
|
||||
// Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
|
||||
// //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);
|
||||
}
|
||||
|
||||
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) {
|
||||
Neuron newNeuroid = new(this.cluster.cluster, "New neuron");
|
||||
newNeuroid.AddReceiver(nucleus);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user