Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.XR.Interaction.Toolkit.AR;
- namespace DrivewayMode
- {
- public class DrivewayPlacementManager : MonoBehaviour
- {
- GameObject _chosenPrefab;
- [SerializeField]
- ARPlacementInteractable _placementInteractable;
- GameObject _placedObject;
- ARPlacementInteractable PlacementInteractable { get {
- if (_placementInteractable == null)
- {
- _placementInteractable = FindFirstObjectByType<ARPlacementInteractable>();
- if (_placementInteractable == null)
- {
- Debug.LogError("#### No Placement interactable!");
- }
- }
- return _placementInteractable;
- } }
- private void Start()
- {
- Debug.Log("#### Start");
- ARObjectPlacementEvent aRObjectPlacedEvent = PlacementInteractable.objectPlaced;
- aRObjectPlacedEvent.AddListener(ObjectPlaced);
- Debug.Log($"#### Set up ARObjectPlacementEvent: {aRObjectPlacedEvent}");
- }
- private void ObjectPlaced(ARObjectPlacementEventArgs placementEventArgs)
- {
- Debug.Log($"#### Placed {placementEventArgs.placementObject}");
- _placedObject = placementEventArgs.placementObject;
- }
- public void ScaleObject(float scale)
- {
- Debug.Log($"#### Placed: {_placedObject} Scale: {scale}");
- if (_placedObject != null)
- {
- _placedObject.transform.localScale = Vector3.one * scale;
- }
- }
- public void SetPrefab(GameObject prefab)
- {
- _chosenPrefab = prefab;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement