-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UILineRenderer mesh not updating in Editor scene view #127
Comments
On 2017.03.16 18:54, @SimonDarksideJ commented: |
On 2017.03.16 18:59, @SimonDarksideJ commented: |
On 2017.03.16 21:43, @SimonDarksideJ commented: for reference (while I look at generalising the script a bit more for all primitives and sorting the screen position issue), here's the script I have (try not to laugh at the fix) [CustomEditor(typeof(UILineRenderer))]
public class BezierLineRendererEditor : Editor
{
void OnSceneGUI()
{
UILineRenderer curveRenderer = target as UILineRenderer;
if (curveRenderer.Points.Length < 2)
{
return;
}
var oldMatrix = Handles.matrix;
var transform = curveRenderer.GetComponent<RectTransform>();
Handles.matrix = transform.localToWorldMatrix;
var points = curveRenderer.Points;
for (int i = 0; i < points.Length - 1; i += 2)
{
Handles.DrawLine(points[i], points[i + 1]);
}
for (int i = 0; i < points.Length; ++i)
{
using (var check = new EditorGUI.ChangeCheckScope())
{
var p = Handles.PositionHandle(points[i], Quaternion.identity);
if (check.changed)
{
Undo.RecordObject(curveRenderer, "Changed Curve Position");
curveRenderer.Points[i] = p;
curveRenderer.transform.gameObject.SetActive(false);
curveRenderer.transform.gameObject.SetActive(true);
}
}
}
Handles.matrix = oldMatrix;
}
} |
On 2017.03.16 21:51, Jason Horsburgh commented: Just so you know, this editor is for a fairly specific use-case for a game I'm working on so you don't have to worry too much about trying to mould this into something more general, however, I'm always glad when something gives me inspiration so hope it's helpful. |
On 2017.04.13 13:03, @SimonDarksideJ commented: |
On 2017.04.13 13:03 @SimonDarksideJ modified issue: |
On 2020.07.12 06:06, Andrew Peysakhovich commented: After some digging in the UI system internals, I’ve figured out that canvas renderer is not getting refreshed while it has valid mesh available, so instead of toggling the object off and on I just force called internal refresh method of the canvas renderer via reflection, and it’s worked!
|
On 2020.07.12 06:45, Andrew Peysakhovich commented: Just call Why almost not hacky then? From Unity docs:
So, |
On 2020.07.13 12:05, @SimonDarksideJ commented: |
On 2020.07.13 19:16, Andrew Peysakhovich commented: @simon Jackson Sorry if my wording was confusing - my comment is not directly related to the Extensions project. I just faced the same issue while developing my own editor for my own line renderer, and wanted to share the possible solution I’ve found. |
Issue created by Jason Horsburgh as Bitbucket Issue #127 on 2017.03.16 17:53.
I've created a custom editor to help me lay out bezier curves on a UILineRenderer.
It creates position handles to move the 4 points on the renderer, and calls SetVerticesDirty() if the Editor reports a change. I can see how this is supposed to work but the line is not updating its position in the scene view. The mesh will update if you change focus of the window or even click the 'points' foldout in the inspector but will not update while moving the handle.
Do you have any pointers that would help me look into the issue?
I've added the basic editor code here since it's not too long:
Just in case you try and use this for testing: the handles also don't appear to match up to where the line actually generates its points but that's not important for this issue.
The text was updated successfully, but these errors were encountered: