Advertisement
DugganSC

Untitled

Apr 16th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.XR.Interaction.Toolkit.AR;
  6.  
  7. namespace DrivewayMode
  8. {
  9. public class DrivewayPlacementManager : MonoBehaviour
  10. {
  11. GameObject _chosenPrefab;
  12. [SerializeField]
  13. ARPlacementInteractable _placementInteractable;
  14. GameObject _placedObject;
  15.  
  16. ARPlacementInteractable PlacementInteractable { get {
  17. if (_placementInteractable == null)
  18. {
  19. _placementInteractable = FindFirstObjectByType<ARPlacementInteractable>();
  20. if (_placementInteractable == null)
  21. {
  22. Debug.LogError("#### No Placement interactable!");
  23. }
  24. }
  25. return _placementInteractable;
  26. } }
  27.  
  28. private void Start()
  29. {
  30. Debug.Log("#### Start");
  31. ARObjectPlacementEvent aRObjectPlacedEvent = PlacementInteractable.objectPlaced;
  32. aRObjectPlacedEvent.AddListener(ObjectPlaced);
  33. Debug.Log($"#### Set up ARObjectPlacementEvent: {aRObjectPlacedEvent}");
  34. }
  35.  
  36. private void ObjectPlaced(ARObjectPlacementEventArgs placementEventArgs)
  37. {
  38. Debug.Log($"#### Placed {placementEventArgs.placementObject}");
  39. _placedObject = placementEventArgs.placementObject;
  40. }
  41.  
  42. public void ScaleObject(float scale)
  43. {
  44. Debug.Log($"#### Placed: {_placedObject} Scale: {scale}");
  45. if (_placedObject != null)
  46. {
  47. _placedObject.transform.localScale = Vector3.one * scale;
  48. }
  49. }
  50.  
  51. public void SetPrefab(GameObject prefab)
  52. {
  53. _chosenPrefab = prefab;
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement