private void InstantiateFromCode(Vector3?position = null, Quaternion?rotation = null) { panObject = GameObject.CreatePrimitive(PrimitiveType.Quad); panObject.EnsureComponent <BoxCollider>(); panObject.transform.position = position != null ? (Vector3)position : Vector3.forward; panObject.transform.rotation = rotation != null ? (Quaternion)rotation : Quaternion.identity; panZoom = panObject.AddComponent <HandInteractionPanZoom>(); panObject.AddComponent <NearInteractionTouchable>(); meshFilter = panZoom.GetComponent <MeshFilter>(); material = panZoom.GetComponent <Renderer>().material; }
/// <summary> /// Instantiates a slate from the default prefab at position and rotation /// </summary> private void InstantiateFromPrefab(Vector3?position = null, Quaternion?rotation = null) { UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(slatePrefabAssetPath, typeof(UnityEngine.Object)); panObject = UnityEngine.Object.Instantiate(prefab) as GameObject; Assert.IsNotNull(panObject); panObject.transform.position = position != null ? (Vector3)position : Vector3.forward; panObject.transform.rotation = rotation != null ? (Quaternion)rotation : Quaternion.identity; panZoom = panObject.GetComponentInChildren <HandInteractionPanZoom>(); Assert.IsNotNull(panZoom); meshFilter = panZoom.GetComponent <MeshFilter>(); material = panZoom.GetComponent <Renderer>().material; }