Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ObjectsManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Microsoft.MixedReality.Toolkit.UI;
public class ObjectsManager : MonoBehaviour
{
    public GameObject cube;
public void OnButtonClicked()
    {
        GameObject tmp = Instantiate(cube);
        var size = tmp.GetComponent<BoundingBox>().TargetBounds.size;
        var pos = Camera.main.transform.TransformPoint(0.0f0.0fsize.z + 0.8f);
        var dir = Quaternion.LookRotation(pos - Camera.main.transform.positionVector3.up);
        dir.z = 0;
        dir.x = 0;
        tmp.transform.position = Camera.main.transform.position + dir * new Vector3(0.0f0.0fsize.z + 0.8f);
var dif = Camera.main.transform.position - tmp.transform.position;
        tmp.transform.rotation = Quaternion.LookRotation(new Vector3(dif.x0dif.z));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment