private void CreateFlowerButtons(List <Flower> flowers) { GridObjectCollection buttonCollection = commandPanel.GetComponentInChildren <GridObjectCollection>(); ScrollingObjectCollection buttonCollectionScroll = commandPanel.GetComponentInChildren <ScrollingObjectCollection>(); float n = 0.0f; foreach (Flower flower in flowers) { GameObject button = GameObject.Instantiate <GameObject>(flowerButtonPrefab, buttonCollection.transform.position, Quaternion.identity); button.transform.parent = buttonCollection.transform; FlowerProperties buttonFlowerProperties = button.GetComponentInChildren <FlowerProperties>(); buttonFlowerProperties.Name = flower.Name; buttonFlowerProperties.PlantingRadius = flower.PlantingRadius; TextMeshPro[] buttonText = button.GetComponentsInChildren <TextMeshPro>(); foreach (TextMeshPro text in buttonText) { text.text = flower.Name; } Interactable buttonInteractable = button.GetComponentInChildren <Interactable>(); buttonInteractable.OnClick.AddListener(() => SelectRadius(button)); n += 0.05f; } buttonCollection.UpdateCollection(); buttonCollectionScroll.UpdateContent(); buttonCollectionScroll.gameObject.SetActive(false); }
private void Start() { scrollObeObjectCollectionGameObject = transform.GetChild(1).GetChild(0).GetChild(1).gameObject; scrollingObjectCollection = scrollObeObjectCollectionGameObject.GetComponent <ScrollingObjectCollection>(); // result0 = transform.GetChild(1).GetChild(0).GetChild(1).GetChild(0).GetChild(0).gameObject; // result1 = transform.GetChild(1).GetChild(0).GetChild(1).GetChild(0).GetChild(0).gameObject; // result2 = transform.GetChild(1).GetChild(0).GetChild(1).GetChild(0).GetChild(0).gameObject; HandMenu = transform.GetChild(2).gameObject; HandMenu.SetActive(false); HandMenuMap = transform.GetChild(3).gameObject; HandMenuMap.SetActive(false); backButtonObject = transform.GetChild(0).GetChild(2).GetChild(1).gameObject; backInteractable = backButtonObject.GetComponent <Interactable>(); BackButton_AddOnClick(backInteractable); ExploreButton = transform.GetChild(0).GetChild(2).GetChild(0).gameObject; ExploreInteractable = ExploreButton.GetComponent <Interactable>(); ExploreButton_AddOnClick(ExploreInteractable); transform.gameObject.SetActive(false); PoiCoordinatesObjects = new Dictionary <int, POICoordinatesObject>(); webTextured = transform.gameObject.AddComponent <WebTextured>(); }
private void OnSceneGUI() { ScrollingObjectCollection scrollContainer = (ScrollingObjectCollection)target; MRTKtmp = Shader.Find("Mixed Reality Toolkit/TextMeshPro"); if (scrollContainer.ClippingObject == null) { return; } if (Event.current.type == EventType.Repaint) { DisplayTouchPlane(scrollContainer); // Display the item number on the list items for (int i = 0; i <= nodeList.arraySize - 1; i++) { var node = nodeList.GetArrayElementAtIndex(i); Transform nodeTransform = node.FindPropertyRelative("Transform").objectReferenceValue as Transform; if (nodeTransform == null) { continue; } Vector3 cp = nodeTransform.position; UnityEditor.Handles.Label(cp, new GUIContent(i.ToString())); } } }
private void OnEnable() { // Make sure we find a collection if (scrollCollection == null) { scrollCollection = GetComponentInChildren <ScrollingObjectCollection>(); } }
public void SelectRadius(GameObject button) { FlowerProperties buttonFlowerProperties = button.GetComponentInChildren <FlowerProperties>(); this.currentPlantRadius = buttonFlowerProperties.PlantingRadius; ScrollingObjectCollection buttonCollectionScroll = commandPanel.GetComponentInChildren <ScrollingObjectCollection>(); buttonCollectionScroll.gameObject.SetActive(false); }
public void MakeScrollingList() { if (scrollView == null) { GameObject newScroll = new GameObject("Scrolling Object Collection"); newScroll.transform.parent = scrollPositionRef ? scrollPositionRef : transform; newScroll.transform.localPosition = Vector3.zero; newScroll.transform.localRotation = Quaternion.identity; newScroll.SetActive(false); scrollView = newScroll.AddComponent <ScrollingObjectCollection>(); // Prevent the scrolling collection from running until we're done dynamically populating it. scrollView.CellWidth = cellWidth; scrollView.CellHeight = cellHeight; scrollView.CellDepth = cellDepth; scrollView.CellsPerTier = cellsPerTier; scrollView.TiersPerPage = tiersPerPage; } gridObjectCollection = scrollView.GetComponentInChildren <GridObjectCollection>(); if (gridObjectCollection == null) { GameObject collectionGameObject = new GameObject("Grid Object Collection"); collectionGameObject.transform.position = scrollView.transform.position; collectionGameObject.transform.rotation = scrollView.transform.rotation; gridObjectCollection = collectionGameObject.AddComponent <GridObjectCollection>(); gridObjectCollection.CellWidth = cellWidth; gridObjectCollection.CellHeight = cellHeight; gridObjectCollection.SurfaceType = ObjectOrientationSurfaceType.Plane; gridObjectCollection.Layout = LayoutOrder.ColumnThenRow; gridObjectCollection.Columns = cellsPerTier; gridObjectCollection.Anchor = LayoutAnchor.UpperLeft; scrollView.AddContent(collectionGameObject); } if (!lazyLoad) { for (int i = 0; i < numItems; i++) { MakeItem(dynamicItem); } scrollView.gameObject.SetActive(true); gridObjectCollection.UpdateCollection(); } else { if (loader != null) { loader.SetActive(true); } StartCoroutine(UpdateListOverTime(loader, itemsPerFrame)); } }
private void OnEnable() { cellHeight = serializedObject.FindProperty("cellHeight"); cellWidth = serializedObject.FindProperty("cellWidth"); cellDepth = serializedObject.FindProperty("cellDepth"); cellsPerTier = serializedObject.FindProperty("cellsPerTier"); canScroll = serializedObject.FindProperty("canScroll"); scrollDirection = serializedObject.FindProperty("scrollDirection"); maskEditMode = serializedObject.FindProperty("maskEditMode"); maskEnabled = serializedObject.FindProperty("maskEnabled"); colliderEditMode = serializedObject.FindProperty("colliderEditMode"); tiersPerPage = serializedObject.FindProperty("tiersPerPage"); useCameraPreRender = serializedObject.FindProperty("useOnPreRender"); handDeltaScrollThreshold = serializedObject.FindProperty("handDeltaScrollThreshold"); velocityType = serializedObject.FindProperty("typeOfVelocity"); velocityMultiplier = serializedObject.FindProperty("velocityMultiplier"); velocityDampen = serializedObject.FindProperty("velocityDampen"); bounceMultiplier = serializedObject.FindProperty("bounceMultiplier"); animationCurve = serializedObject.FindProperty("paginationCurve"); animationLength = serializedObject.FindProperty("animationLength"); disableClippedGameObjects = serializedObject.FindProperty("disableClippedGameObjects"); disableClippedRenderers = serializedObject.FindProperty("disableClippedRenderers"); clickEvent = serializedObject.FindProperty("OnClick"); touchStartedEvent = serializedObject.FindProperty("OnTouchStarted"); touchEndedEvent = serializedObject.FindProperty("OnTouchEnded"); momentumStartedEvent = serializedObject.FindProperty("OnMomentumStarted"); momentumEndedEvent = serializedObject.FindProperty("OnMomentumEnded"); // Serialized properties for visualization releaseThresholdFront = serializedObject.FindProperty("releaseThresholdFront"); releaseThresholdBack = serializedObject.FindProperty("releaseThresholdBack"); releaseThresholdLeftRight = serializedObject.FindProperty("releaseThresholdLeftRight"); releaseThresholdTopBottom = serializedObject.FindProperty("releaseThresholdTopBottom"); frontTouchDistance = serializedObject.FindProperty("frontTouchDistance"); scrollView = (ScrollingObjectCollection)target; MRTKtmp = Shader.Find("Mixed Reality Toolkit/TextMeshPro"); if (labelStyle == null) { labelStyle = new GUIStyle(); labelStyle.normal.textColor = Color.white; } }
void Start() { querymenu = transform.gameObject;; transform.gameObject.SetActive(false); queryMenuPosition = GetComponent <SolverHandler>().AdditionalOffset; initRadialView = GetComponent <RadialView>(); queryList = new Dictionary <int, GameObject>(); scrollObeObjectCollectionGameObject = querymenu.transform.GetChild(2).gameObject; scrollingObjectCollection = scrollObeObjectCollectionGameObject.GetComponent <ScrollingObjectCollection>(); searchButton = transform.GetChild(3).gameObject; searchButton.GetComponent <Interactable>().OnClick.AddListener((() => searchClick())); ErrorDialog = transform.GetChild(8).gameObject; ErrorDialog.SetActive(false); ErrorButton = transform.GetChild(8).GetChild(2).GetChild(0).gameObject; ErrorButton.GetComponent <Interactable>().OnClick.AddListener((() => backClick())); }
private void Start() { transform.gameObject.SetActive(false); generate_button = transform.GetChild(2).GetChild(0).gameObject; generate_interactable = generate_button.GetComponent <Interactable>(); generate_AddOnClick(generate_interactable); back_button = transform.GetChild(2).GetChild(1).gameObject; back_interactable = back_button.GetComponent <Interactable>(); back_AddOnClick(back_interactable); ResetBaselButton = transform.GetChild(2).GetChild(2).gameObject; resetBaselInteractable = ResetBaselButton.GetComponent <Interactable>(); resetBaselAddOnClick(resetBaselInteractable); journeyButton = transform.GetChild(6).gameObject; journeyInteractable = journeyButton.GetComponent <Interactable>(); journey_AddOnClick(journeyInteractable); cancelButton = transform.GetChild(7).gameObject; cancelInteractable = cancelButton.GetComponent <Interactable>(); cancel_AddOnClick(cancelInteractable); stopARMenuButton = transform.GetChild(10).gameObject; stopARMenuButtonInteractable = stopARMenuButton.GetComponent <Interactable>(); stopAR_AddOnclick(stopARMenuButtonInteractable); scrollObeObjectCollectionGameObject = transform.GetChild(4).GetChild(1).gameObject; scrollingObjectCollection = scrollObeObjectCollectionGameObject.GetComponent <ScrollingObjectCollection>(); slider = transform.GetChild(5).gameObject; POIQuery = transform.GetChild(4).gameObject; miniMap = transform.GetChild(8).gameObject; MiniMapRenderer = miniMap.GetComponent <MapRenderer>(); miniMap.SetActive(false); BigMapRenderer = transform.parent.GetChild(5).GetComponent <MapRenderer>(); mapMenu = transform.gameObject; mainMenuButtons = transform.GetChild(2).gameObject; Arrow = transform.GetChild(11).gameObject; ActiveList = new List <GameObject>(); ZoomSliderInit(); }
public void MakeScrollingList() { if (scrollCollection == null) { GameObject newScroll = new GameObject("Scrolling Object Collection"); newScroll.transform.parent = transform; newScroll.transform.localPosition = new Vector3(-0.0178f, 0.0165f, -0.0047f); newScroll.transform.localRotation = Quaternion.identity; newScroll.SetActive(false); scrollCollection = newScroll.AddComponent <ScrollingObjectCollection>(); // Prevent the scrolling collection from running until we're done dynamically populating it. scrollCollection.SetUpAtRuntime = false; scrollCollection.CellHeight = 0.032f; scrollCollection.CellWidth = 0.032f; scrollCollection.Tiers = 3; scrollCollection.ViewableArea = 5; scrollCollection.DragTimeThreshold = 0.75f; scrollCollection.HandDeltaMagThreshold = 0.8f; scrollCollection.TypeOfVelocity = ScrollingObjectCollection.VelocityType.FalloffPerItem; } if (!lazyLoad) { for (int i = 0; i < numItems; i++) { MakeItem(dynamicItem, scrollCollection.transform); } scrollCollection.gameObject.SetActive(true); scrollCollection.UpdateCollection(); } else { if (loader != null) { loader.SetActive(true); } StartCoroutine(UpdateListOverTime(loader, itemsPerFrame)); } }
/// <summary> /// Displays the touch plane used for scrolling (and releasing). /// </summary> private void DisplayTouchPlane(ScrollingObjectCollection container) { Color arrowColor = Color.cyan; Vector3 center; if (container.ClippingObject == null) { return; } var scrollContainer = (ScrollingObjectCollection)target; // now that its running lets show the press plane so users have feedback about touch center = scrollContainer.transform.TransformPoint(Vector3.forward * -1.0f * releaseDistance.floatValue); UnityEditor.Handles.color = arrowColor; float arrowSize = UnityEditor.HandleUtility.GetHandleSize(center) * 0.75f; container.transform.rotation.ToAngleAxis(out float ang, out Vector3 currRotAxis); Vector3 rightDelta = container.transform.right * container.ClippingObject.transform.localScale.x; Vector3 upDelta = container.transform.up * container.ClippingObject.transform.localScale.y; Quaternion rot = Quaternion.LookRotation(container.transform.forward * -1.0f, container.transform.up); UnityEditor.Handles.ArrowHandleCap(0, center + (rightDelta * 0.5f) - (upDelta * 0.5f), rot, arrowSize, EventType.Repaint); Vector3[] points = new Vector3[4]; points[0] = center; points[1] = center + rightDelta; points[2] = center + rightDelta - upDelta; points[3] = center - upDelta; UnityEditor.Handles.DrawSolidRectangleWithOutline(points, new Color(0.85f, 1.0f, 1.0f, 0.1f), arrowColor); GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = Color.white; UnityEditor.Handles.Label(center + (rightDelta * 0.5f) - (upDelta * 0.5f), new GUIContent("touch plane", "The plane which the finger will need to cross in order for the touch to be calculated as a scroll or release."), labelStyle); }
public void TogglePlantsMenu() { ScrollingObjectCollection buttonCollectionScroll = commandPanel.GetComponentInChildren(typeof(ScrollingObjectCollection), true) as ScrollingObjectCollection; buttonCollectionScroll.gameObject.SetActive(!buttonCollectionScroll.gameObject.activeSelf); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); ScrollingObjectCollection scrollContainer = (ScrollingObjectCollection)target; EditorGUILayout.LabelField("General Properties", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(canScroll); EditorGUILayout.PropertyField(scrollDirection); EditorGUILayout.PropertyField(setUpAtRuntime); EditorGUILayout.PropertyField(useCameraPreRender); EditorGUILayout.Space(); } EditorGUILayout.LabelField("Collection Properties", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(sorting); EditorGUILayout.PropertyField(cellWidth); EditorGUILayout.PropertyField(cellHeight); EditorGUILayout.PropertyField(tiers); EditorGUILayout.PropertyField(viewableArea); EditorGUILayout.Space(); } EditorGUILayout.Space(); if (GUILayout.Button("Update Collection")) { scrollContainer.UpdateCollection(); EditorUtility.SetDirty(scrollContainer); } EditorGUILayout.Space(); EditorGUILayout.HelpBox("In order for a ScrollableObjectCollection to work properly with PressableButton, ReleaseOnTouchEnd must be inactive.", MessageType.Info); if (GUILayout.Button("Set Up PressableButtons")) { PressableButton[] pBs = scrollContainer.transform.GetComponentsInChildren <PressableButton>(); foreach (PressableButton p in pBs) { p.ReleaseOnTouchEnd = false; } PhysicalPressEventRouter[] routers = scrollContainer.transform.GetComponentsInChildren <PhysicalPressEventRouter>(); foreach (PhysicalPressEventRouter r in routers) { r.InteractableOnClick = PhysicalPressEventRouter.PhysicalPressEventBehavior.EventOnClickCompletion; } } EditorGUILayout.LabelField("Scrolling Properties", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(dragTimeThreshold); EditorGUILayout.PropertyField(handDeltaMagThreshold); EditorGUILayout.PropertyField(useNearScrollBoundary); EditorGUILayout.Space(); EditorGUILayout.PropertyField(occlusionPositionPadding); EditorGUILayout.PropertyField(occlusionScalePadding); EditorGUILayout.Space(); EditorGUILayout.PropertyField(animationCurve); EditorGUILayout.PropertyField(animationLength); EditorGUILayout.PropertyField(disableClippedItems); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Velocity Properties", EditorStyles.boldLabel); using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(velocityType); if (velocityType.enumValueIndex <= 1) { EditorGUILayout.PropertyField(velocityMultiplier); EditorGUILayout.PropertyField(velocityDampen); EditorGUILayout.PropertyField(bounceMultiplier); } } EditorGUILayout.Space(); showUnityEvents = EditorGUILayout.Foldout(showUnityEvents, "Unity Events: ", true); if (showUnityEvents) { using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(clickEvent); EditorGUILayout.PropertyField(touchEvent); EditorGUILayout.PropertyField(untouchEvent); EditorGUILayout.PropertyField(momentumEvent); } } EditorGUILayout.Space(); showOverrideButtons = EditorGUILayout.Foldout(showOverrideButtons, "Scrolling debug buttons", true); EditorGUILayout.Space(); if (showOverrideButtons) { using (new EditorGUI.IndentLevelScope()) { animateTransition = EditorGUILayout.Toggle("Animate", animateTransition); using (new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Page Up")) { scrollContainer.PageBy(1, animateTransition); } if (GUILayout.Button("Page Down")) { scrollContainer.PageBy(-1, animateTransition); } } using (new EditorGUILayout.HorizontalScope()) { amountOfLinesToMoveTo = EditorGUILayout.IntField(amountOfLinesToMoveTo); if (GUILayout.Button("Move By Tiers")) { scrollContainer.MoveByLines(amountOfLinesToMoveTo, animateTransition); } } using (new EditorGUILayout.HorizontalScope()) { amountOfItemsToMoveBy = EditorGUILayout.IntField(amountOfItemsToMoveBy); if (GUILayout.Button("Move By Items")) { scrollContainer.MoveByItems(amountOfItemsToMoveBy, animateTransition); } } using (new EditorGUILayout.HorizontalScope()) { indexToMoveTo = EditorGUILayout.IntField(indexToMoveTo); if (GUILayout.Button("Move To Index")) { scrollContainer.MoveTo(indexToMoveTo, animateTransition); } } } } serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < nodeList.arraySize; i++) { var node = nodeList.GetArrayElementAtIndex(i); Transform nodeTransform = node.FindPropertyRelative("Transform").objectReferenceValue as Transform; if (nodeTransform == null) { continue; } if (!CheckForStandardShader(nodeTransform.GetComponentsInChildren <Renderer>())) { Debug.LogWarning(nodeTransform.name + " has a renderer that is not using " + StandardShaderUtility.MrtkStandardShaderName + ". This will result in unexpected results with ScrollingObjectCollection"); } } } }