B
BettyWhite

  • Nov 27, 2023
  • Joined Nov 15, 2023
  • Anthony

    Thanks for your response, I now have it partially working!

    I have added the SelectableByFinger component to my marker and added my DisplayUI function to the OnSelected list in the Inspector. I also modified by Marker script to inherit from TouchSelectableBehaviour and I added:

    // when selected
    protected override void OnSelected(TouchSelect select)
    {
         // tell object to display UI
         this.gameObject.GetComponent<MapMarker>().DisplayPreview();
    }

    I also added a listener based on FocusOnClick so that it focuses on the marker. Looks great!
    CameraEvents.OnRequestObjectFocus?.Invoke(gameObject, true);

    Now it will focus on the marker 80% of the time the first time I select it, and then if I don't move the camera I can still select other markers and have my DisplayUI function execute anywhere between 1 and 3 times before it stops completely. And if I move the camera then I stop being able to select any markers at all (or execute the DisplayUI function).

    I also found that the function associated with the touch (DisplayPreview) executed twice, so I added a co-routine delay so that it only executes once.

    Could you explain what else I'm missing here and why it's stopping? And please let me know if you need any more information.

    Thanks for your time!

    • Hi there!

      It looks like you have some terrific selection options, but I am having trouble because there are so many touch variations. Could you please add some more examples of how selection can be added to objects via script? These would be very useful in the demo scenes as well.

      My situation: I have objects that I am instantiating at runtime that I want to make selectable and to execute additional functions when they are selected (specifically, passing the information the object contains to the UI). From what I understand, I want to be adding them to the list of selectables on the TouchCameraInputs object by script. Are these events that I should be adding or objects?

      Could you please demonstrate how to make an object selectable (by finger and mouse) via script?

      Here is how I am currently trying to do it when I instantiate map markers:

      marker.AddComponent<TouchSelectable>();
      mainCamera.GetComponent<SelectByFinger>().Selectables.Add(marker.GetComponent<TouchSelectable>());

      Many thanks!

      • It only took me 4 hours, but I did it!

        Here's what I put in my TutorialManager:

        bool isZooming = IsInputMatching(CameraBase.InputMapFingerPinch.ZoomAndRotate);
        if(isZooming){
            CompleteObjective();
        }

        And I added this to the TutorialManager as well:

        protected bool IsInputMatching(CameraBase.InputMapFingerPinch action)
        {
        CameraBase.InputMapFingerPinch twoFingerPinch = CameraBase.InputMapFingerPinch.ZoomAndRotate;
                    
             if (twoFingerPinch == action && CameraInputs.GetFingerCount() == 2)
                  return true;
             return false;
        }

        And as for setting the zoom with code, I just used:
        camera.MoveCameraTo(focusPosition);

        Boom!

      • Hi there,

        I have two fairly simple questions as listed in the title.

        1. How can I set the zoom with code? (i.e. zoom the camera in to a particular level)
          and
        2. How can I execute functions on zoom? At the moment the closest I can get is by adding functions to FingerTap > OnFinger.

        Thanks! Love the asset.