Here are the examples of the csharp api UnityEngine.GUI.BeginScrollView(UnityEngine.Rect, UnityEngine.Vector2, UnityEngine.Rect, bool, bool) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
View Source File : ComboBox.cs
License : GNU Lesser General Public License v3.0
Project Creator : BepInEx
License : GNU Lesser General Public License v3.0
Project Creator : BepInEx
public void Show(Action<int> onItemSelected)
{
if (forceToUnShow)
{
forceToUnShow = false;
isClickedComboButton = false;
}
var done = false;
var controlID = GUIUtility.GetControlID(FocusType.Preplacedive);
Vector2 currentMousePosition = Vector2.zero;
if (Event.current.GetTypeForControl(controlID) == EventType.mouseUp)
{
if (isClickedComboButton)
{
done = true;
currentMousePosition = Event.current.mousePosition;
}
}
if (GUI.Button(Rect, ButtonContent, buttonStyle))
{
if (useControlID == -1)
{
useControlID = controlID;
isClickedComboButton = false;
}
if (useControlID != controlID)
{
forceToUnShow = true;
useControlID = controlID;
}
isClickedComboButton = true;
}
if (isClickedComboButton)
{
GUI.enabled = false;
GUI.color = new Color(1, 1, 1, 2);
var location = GUIUtility.GUIToScreenPoint(new Vector2(Rect.x, Rect.y + listStyle.CalcHeight(listContent[0], 1.0f)));
var size = new Vector2(Rect.width, listStyle.CalcHeight(listContent[0], 1.0f) * listContent.Length);
var innerRect = new Rect(0, 0, size.x, size.y);
var outerRectScreen = new Rect(location.x, location.y, size.x, size.y);
if (outerRectScreen.yMax > _windowYmax)
{
outerRectScreen.height = _windowYmax - outerRectScreen.y;
outerRectScreen.width += 20;
}
if (currentMousePosition != Vector2.zero && outerRectScreen.Contains(GUIUtility.GUIToScreenPoint(currentMousePosition)))
done = false;
CurrentDropdownDrawer = () =>
{
GUI.enabled = true;
var scrpos = GUIUtility.ScreenToGUIPoint(location);
var outerRectLocal = new Rect(scrpos.x, scrpos.y, outerRectScreen.width, outerRectScreen.height);
GUI.Box(outerRectLocal, GUIContent.none,
new GUIStyle { normal = new GUIStyleState { background = ConfigurationManager.WindowBackground } });
_scrollPosition = GUI.BeginScrollView(outerRectLocal, _scrollPosition, innerRect, false, false);
{
const int initialSelectedItem = -1;
var newSelectedItemIndex = GUI.SelectionGrid(innerRect, initialSelectedItem, listContent, 1, listStyle);
if (newSelectedItemIndex != initialSelectedItem)
{
onItemSelected(newSelectedItemIndex);
isClickedComboButton = false;
}
}
GUI.EndScrollView(true);
};
}
if (done)
isClickedComboButton = false;
}
19
View Source File : SF_EditorNodeBrowser.cs
License : MIT License
Project Creator : XINCGer
License : MIT License
Project Creator : XINCGer
public void OnLocalGUI( Rect rect ) {
if( IsPlacing() && Event.current.type == EventType.mouseUp && Event.current.button == 1 ) {
CancelDrag();
Event.current.Use();
}
CheckInitializeStyles();
//EditorGUIUtility.LookLikeInspector();
if( styleCategory.alignment != TextAnchor.MiddleLeft )
InitializeStyles();
Rect toolbarRect = new Rect( rect );
toolbarRect.height = 19;
Rect searchRect = new Rect( toolbarRect );
searchRect.width -= 19;
searchRect.y += 1;
Rect searchCancelRect = new Rect( searchRect );
searchCancelRect.x += searchCancelRect.width;
searchCancelRect.width = 19;
// Command/ctrl + F // TODO
/*
if( SF_GUI.HoldingControl() &&
Event.current.keyCode == KeyCode.F &&
Event.current.type == EventType.keyDown &&
GUI.GetNameOfFocusedControl() != searchBoxName){
Event.current.character = (char)0; // We're done using F now
Event.current.Use();
GUI.FocusControl(searchBoxName); // Focus search field
Event.current.character = (char)0; // Stop! No more characters! Please!
}
*/
// Draw Toolbar
GUI.Box( toolbarRect, "", styleToolbar );
prevString = searchString.Trim();
GUI.SetNextControlName( searchBoxName );
searchString = EditorGUI.TextField( searchRect, searchString, styleSearchField );
if( GUI.Button(searchCancelRect, "", styleSearchCancel ) ) {
searchString = "";
GUI.FocusControl( null );
}
if( searchString.Trim() != prevString )
OnSearchStringChanged();
// Scroll view stuff
Rect panelRect = new Rect( rect );
panelRect.yMin += toolbarRect.height - 1;
panelRect.height -= toolbarRect.height;
Rect scrollRect = new Rect( panelRect );
scrollRect.y = scrollPos.y;
// Calc insides height
//Debug.Log(panelRect.height);
scrollRect.height = Mathf.Max( panelRect.height, innerHeight );
scrollRect.width -= 15;
Rect btnRect = new Rect( panelRect.x, panelRect.y - toolbarRect.height, rect.width - 16, styleCategory.fixedHeight );
innerHeight = 0;
float innerStartY = 0f;
scrollPos = GUI.BeginScrollView( panelRect, scrollPos, scrollRect, false, true /*GUILayout.Width( rect.wi )*/ );
{
if(Event.current.type == EventType.layout)
innerStartY = btnRect.y;
if( GetNodeList().Count > 0 ) {
foreach( SF_EditorNodeData entry in GetNodeList() ) {
if( entry.category != prevCategory ) {
DrawCategory(entry.category, ref btnRect );
prevCategory = entry.category;
}
DrawButton( entry, ref btnRect );
}
} else {
GUI.color = Color.gray;
GUI.Label(btnRect, "No nodes matched" );
GUI.color = Color.white;
}
if(Event.current.type == EventType.layout){
innerHeight = btnRect.yMax - innerStartY;
//Debug.Log ("Inner: " + innerHeight + ", Panel: " + panelRect.height);
}
}
GUI.EndScrollView();
UpdateDrag();
}