// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void Awake() { Application.targetFrameRate = 60; scrollView = GetComponentInChildren <exUIScrollView>(); clipping = GetComponentInChildren <exClipping>(); for (int i = 0; i < userInfos.Count; ++i) { GameObject el = Object.Instantiate(elementPrefab) as GameObject; LeaderboardElement leaderboardEL = el.GetComponent <LeaderboardElement>(); UserInfo userInfo = userInfos[i]; if (userInfo.icon != null) { leaderboardEL.Init(userInfo.icon, userInfo.name, userInfo.score); } else { leaderboardEL.Init(userInfo.iconURL, userInfo.name, userInfo.score); } AddElement(el); } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ protected override void DoInspectorGUI() { base.DoInspectorGUI(); EditorGUILayout.PropertyField(draggableProp); EditorGUILayout.PropertyField(dragEffectProp); EditorGUILayout.PropertyField(showConditionProp); EditorGUILayout.PropertyField(contentAnchorProp); EditorGUILayout.PropertyField(contentSizeProp, new GUIContent("Content Size")); EditorGUILayout.PropertyField(allowHorizontalScrollProp); EditorGUILayout.PropertyField(horizontalContentDirProp); EditorGUILayout.PropertyField(allowVerticalScrollProp); EditorGUILayout.PropertyField(verticalContentDirProp); EditorGUILayout.PropertyField(scrollSpeedProp); if (serializedObject.isEditingMultipleObjects == false) { exUIScrollView scrollView = target as exUIScrollView; if (scrollView != null && scrollView.contentAnchor == null && scrollView.transform.childCount > 0) { scrollView.contentAnchor = scrollView.transform.GetChild(0); EditorUtility.SetDirty(target); } } EditorGUILayout.Space(); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public new void OnSceneGUI() { exUIControl ctrl = target as exUIControl; Vector3[] vertices = ctrl.GetLocalVertices(); if (vertices.Length > 0) { Rect aabb = exGeometryUtility.GetAABoundingRect(vertices); Matrix4x4 l2w = ctrl.transform.localToWorldMatrix; // draw control rect vertices = new Vector3[4] { l2w.MultiplyPoint3x4(new Vector3(aabb.xMin, aabb.yMin, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMin, aabb.yMax, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMax, aabb.yMax, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMax, aabb.yMin, 0)), }; exEditorUtility.GL_DrawRectLine(vertices, new Color(1.0f, 0.0f, 0.5f, 1.0f), true); // draw scroll-view content exUIScrollView scrollView = ctrl as exUIScrollView; if (scrollView != null) { aabb.width = scrollView.contentSize.x; aabb.yMin = aabb.yMax - scrollView.contentSize.y; float contentX = (scrollView.horizontalContentDir == exUIScrollView.ContentDirection.LeftToRight) ? 0.0f : (scrollView.contentSize.x - scrollView.width); float contentY = (scrollView.verticalContentDir == exUIScrollView.ContentDirection.TopToBottom) ? 0.0f : (scrollView.contentSize.y - scrollView.height); aabb.center += scrollView.scrollOffset; aabb.center += new Vector2(contentX, contentY); vertices = new Vector3[4] { l2w.MultiplyPoint3x4(new Vector3(aabb.xMin, aabb.yMin, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMin, aabb.yMax, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMax, aabb.yMax, 0)), l2w.MultiplyPoint3x4(new Vector3(aabb.xMax, aabb.yMin, 0)), }; exEditorUtility.GL_DrawRectLine(vertices, new Color(0.0f, 0.5f, 1.0f, 1.0f), true); } } exPlane plane = target as exPlane; if (plane.hasSprite == false) { Vector3 size; Vector3 center; bool changed = ProcessSceneEditorHandles(out size, out center); if (changed) { ApplyPlaneScale(plane, size, center); } } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public override void OnInspectorGUI() { // ======================================================== // Base GUI // ======================================================== base.OnInspectorGUI(); GUILayout.Space(20); // ======================================================== // // ======================================================== serializedObject.Update(); EditorGUILayout.PropertyField(horizontalBarProp); EditorGUILayout.PropertyField(horizontalSliderProp); EditorGUILayout.PropertyField(verticalBarProp); EditorGUILayout.PropertyField(verticalSliderProp); EditorGUILayout.PropertyField(showSliderOnDraggingProp); EditorGUILayout.PropertyField(scrollDirectionProp); EditorGUILayout.PropertyField(decelerationProp); EditorGUILayout.PropertyField(bounceProp); EditorGUILayout.PropertyField(bounceBackDurationProp); serializedObject.ApplyModifiedProperties(); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Update...", GUILayout.Height(20))) { exUIScrollView scrollView = target as exUIScrollView; exUIElement.FindAndAddChild(scrollView); exPlane[] planes = scrollView.contentAnchor.GetComponentsInChildren <exPlane>(); foreach (exPlane plane in planes) { if (plane as exUIElement == false) { scrollView.clipRect.AddPlaneInEditor(plane); } } EditorUtility.SetDirty(this); } GUILayout.EndHorizontal(); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void Awake() { Application.targetFrameRate = 60; scrollView = GetComponentInChildren<exUIScrollView>(); clipping = GetComponentInChildren<exClipping>(); for ( int i = 0; i < userInfos.Count; ++i ) { GameObject el = Object.Instantiate( elementPrefab ) as GameObject; LeaderboardElement leaderboardEL = el.GetComponent<LeaderboardElement>(); UserInfo userInfo = userInfos[i]; if ( userInfo.icon != null ) { leaderboardEL.Init( userInfo.icon, userInfo.name, userInfo.score ); } else { leaderboardEL.Init( userInfo.iconURL, userInfo.name, userInfo.score ); } AddElement(el); } }
static void CreateScrollViewObject() { // create panel object GameObject scrollViewGO = new GameObject("ScrollView"); // GameObject clipRectGO = new GameObject("ClipRect"); clipRectGO.transform.parent = scrollViewGO.transform; exClipping clipRect = clipRectGO.AddComponent <exClipping>(); clipRect.anchor = exPlane.Anchor.TopLeft; // GameObject contentAnchor = new GameObject("ContentAnchor"); contentAnchor.transform.parent = clipRect.transform; // GameObject horizontalBarGO = new GameObject("HorizontalBar"); horizontalBarGO.transform.parent = scrollViewGO.transform; exSpriteBorder horizontalBar = horizontalBarGO.AddComponent <exSpriteBorder>(); // myBorder = AssetDatabase.LoadAssetAtPath("Assets/ex2D_GUI/Resource/GUIBorder/HorizontalScrollBar.asset", // typeof(exGUIBorder)) as exGUIBorder; // elInfo = exAtlasDB.GetElementInfo(myBorder.textureGUID); // if ( elInfo != null ) { // atlas = exEditorHelper.LoadAssetFromGUID<exAtlas>(elInfo.guidAtlas); // index = elInfo.indexInAtlas; // } // horizontalBar.SetBorder( myBorder, atlas, index ); // horizontalBar.Rebuild (); horizontalBar.anchor = exPlane.Anchor.TopLeft; horizontalBar.enabled = false; // GameObject horizontalSliderGO = new GameObject("HorizontalSlider"); horizontalSliderGO.transform.parent = scrollViewGO.transform; exSpriteBorder horizontalSlider = horizontalSliderGO.AddComponent <exSpriteBorder>(); // myBorder = AssetDatabase.LoadAssetAtPath("Assets/ex2D_GUI/Resource/GUIBorder/HorizontalSlider.asset", // typeof(exGUIBorder)) as exGUIBorder; // elInfo = exAtlasDB.GetElementInfo(myBorder.textureGUID); // if ( elInfo != null ) { // atlas = exEditorHelper.LoadAssetFromGUID<exAtlas>(elInfo.guidAtlas); // index = elInfo.indexInAtlas; // } // horizontalSlider.SetBorder( myBorder, atlas, index ); horizontalSlider.anchor = exPlane.Anchor.TopLeft; horizontalSlider.width = 0.0f; horizontalSlider.height = 0.0f; horizontalSlider.enabled = false; // GameObject verticalBarGO = new GameObject("VerticalBar"); verticalBarGO.transform.parent = scrollViewGO.transform; exSpriteBorder verticalBar = verticalBarGO.AddComponent <exSpriteBorder>(); // myBorder = AssetDatabase.LoadAssetAtPath("Assets/ex2D_GUI/Resource/GUIBorder/VerticalScrollBar.asset", // typeof(exGUIBorder)) as exGUIBorder; // elInfo = exAtlasDB.GetElementInfo(myBorder.textureGUID); // if ( elInfo != null ) { // atlas = exEditorHelper.LoadAssetFromGUID<exAtlas>(elInfo.guidAtlas); // index = elInfo.indexInAtlas; // } // verticalBar.SetBorder( myBorder, atlas, index ); // verticalBar.Rebuild (); verticalBar.anchor = exPlane.Anchor.TopLeft; verticalBar.enabled = false; // GameObject verticalSliderGO = new GameObject("VerticalSlider"); verticalSliderGO.transform.parent = scrollViewGO.transform; exSpriteBorder verticalSlider = verticalSliderGO.AddComponent <exSpriteBorder>(); // myBorder = AssetDatabase.LoadAssetAtPath("Assets/ex2D_GUI/Resource/GUIBorder/verticalSlider.asset", // typeof(exGUIBorder)) as exGUIBorder; // elInfo = exAtlasDB.GetElementInfo(myBorder.textureGUID); // if ( elInfo != null ) { // atlas = exEditorHelper.LoadAssetFromGUID<exAtlas>(elInfo.guidAtlas); // index = elInfo.indexInAtlas; // } // verticalSlider.SetBorder( myBorder, atlas, index ); verticalSlider.anchor = exPlane.Anchor.TopLeft; verticalSlider.width = 0.0f; verticalSlider.height = 0.0f; verticalSlider.enabled = false; // exUIScrollView scrollView = scrollViewGO.AddComponent <exUIScrollView>(); scrollView.anchor = exPlane.Anchor.TopCenter; scrollView.horizontalBar = horizontalBar; scrollView.horizontalSlider = horizontalSlider; scrollView.verticalBar = verticalBar; scrollView.verticalSlider = verticalSlider; scrollView.contentAnchor = contentAnchor.transform; scrollView.clipRect = clipRect; scrollView.width = 100.0f; scrollView.height = 100.0f; // Selection.activeObject = scrollViewGO; }