//--------------------------------------------------------------------------------------------- // // Show selected widget and enable its editation // // To right (main) window draws texture for current selected widget // Also render area (rectangle) in the texture witch represents widget // //--------------------------------------------------------------------------------------------- void RenderRightPanel() { // Show selected widget and enable its editation EditorGUILayout.BeginVertical(GUILayout.MinWidth(300)); if (m_SelectedWidget) { Material mat = m_SelectedWidget.GetMaterial(); if (mat && mat.mainTexture) { // Draw texture EditorGUILayout.Separator(); Rect r = GUILayoutUtility.GetLastRect(); // Go a little bit far from border //r.x += 10; //r.y += r.height + 10; // Take zoom into account r.width = mat.mainTexture.width * m_ZoomFactor * (1.0f + m_PlatformShift.x); r.height = mat.mainTexture.height * m_ZoomFactor * (1.0f + m_PlatformShift.y); Rect sourceRect = new Rect(-m_PlatformShift.x, 0.0f, 1.0f + m_PlatformShift.x, 1.0f + m_PlatformShift.y); Graphics.DrawTexture(r, mat.mainTexture, sourceRect, 0, 0, 0, 0, mat); // Edit area ? if (Event.current.type == EventType.Repaint) // values are not correct during other events !!! { m_TexturePosPrepared = true; m_TexturePos.x = r.x; m_TexturePos.y = r.y; m_TextureSize.x = mat.mainTexture.width; m_TextureSize.y = mat.mainTexture.height; //if ((m_SelectedPointIdx != -1) || m_WidgetDrag) if (m_SelectedPointIdx != -1) { MoveWithSelectedVertex(); } } // Draw area rectangle (of selected/edited widget) Rect tmpArea = new Rect(m_EditedArea.Area.x, m_EditedArea.Area.y, m_EditedArea.Area.width, m_EditedArea.Area.height); Vector2 layoutShift = new Vector2(m_PlatformShift.x * m_TextureSize.x * m_ZoomFactor, m_PlatformShift.y * m_TextureSize.y * m_ZoomFactor); GUIEditorUtils.SetClipPoint(m_TexturePos); GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), tmpArea, 0.0f, m_ZoomFactor, layoutShift, true, GUIEditorUtils.COLOR_AREA_EDGE, GUIEditorUtils.COLOR_AREA_POINT, GUIEditorUtils.COLOR_AREA_SELECTED_POINT, true, m_PointSize, m_SelectedPointIdx); //HACK rewrite to DrawLine() later !!!! if (m_EditedArea.UsesGrid9 == true) { GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), new Rect(tmpArea.x + m_EditedArea.Slices.left, tmpArea.y, 0, tmpArea.height), 0.0f, m_ZoomFactor, layoutShift, GUIEditorUtils.COLOR_AREA_SLICE); GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), new Rect(tmpArea.x + tmpArea.width - m_EditedArea.Slices.right, tmpArea.y, 0, tmpArea.height), 0.0f, m_ZoomFactor, layoutShift, GUIEditorUtils.COLOR_AREA_SLICE); GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), new Rect(tmpArea.x, tmpArea.y + m_EditedArea.Slices.top, tmpArea.width, 0), 0.0f, m_ZoomFactor, layoutShift, GUIEditorUtils.COLOR_AREA_SLICE); GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), new Rect(tmpArea.x, tmpArea.y + tmpArea.height - m_EditedArea.Slices.bottom, tmpArea.width, 0), 0.0f, m_ZoomFactor, layoutShift, GUIEditorUtils.COLOR_AREA_SLICE); } //GUIEditorUtils.DrawRect(new Vector2(r.x, r.y), new Rect(0, 0, r.width, r.height), 0.0f, 1.0f, new Vector2(0,0), GUIEditorUtils.COLOR_LAYOUT_AREA); } } EditorGUILayout.EndVertical(); }