コード例 #1
0
ファイル: FeatureCreator.cs プロジェクト: ututrc/ME-UnitySDK
        private void CreateAnnotation(AnnotationElement annotation, Feature feature)
        {
            if (annotation.name.IsNullOrEmpty())
            {
                return;
            }

            AnnotationCreator creator = FindObjectOfType <AnnotationCreator> ();

            if (creator == null)
            {
                return;
            }

            AnnotationsRoot root = feature.gameObject.GetComponentInChildren <AnnotationsRoot> ();

            if (root == null)
            {
                GameObject rootGO = new GameObject("Annotations");
                rootGO.transform.SetParent(feature.transform, false);
                rootGO.transform.localPosition = Vector3.zero;
                root = rootGO.AddComponent <AnnotationsRoot> ();
            }

            AnnotationVisualization.AnnotationData data = new AnnotationVisualization.AnnotationData();
            data.name        = annotation.name;
            data.description = annotation.description;
            data.position    = new Vector3(annotation.ParsePos()[0], annotation.ParsePos()[1], annotation.ParsePos()[2]);

            creator.CreateAnnotation(data, root.gameObject);
        }
コード例 #2
0
    public void CreateAnnotation(AnnotationVisualization.AnnotationData data, GameObject parent)
    {
        if (annotationPrefab == null)
        {
            return;
        }

        Vector3    position = Vector3.zero;
        Quaternion rotation = Quaternion.identity;

        if (data.transform != null)
        {
            position = data.transform.position;
            rotation = data.transform.rotation;
        }
        else
        {
            position = data.position;
            rotation = Quaternion.Euler(data.rotation);
        }

        GameObject annotationInstance = Instantiate(annotationPrefab, position, rotation) as GameObject;

        annotationInstance.transform.SetParent(parent.transform);
        AnnotationVisualization annotationVisualization = annotationInstance.GetComponent <AnnotationVisualization> ();

        if (annotationVisualization != null)
        {
            annotationVisualizations.Add(annotationVisualization);
            annotationVisualization.settings = annotationSettings;
            annotationVisualization.data     = data;
            annotationVisualization.SetImage(data.image);
            annotationVisualization.SetText(data.description);
            annotationVisualization.settings.viewCamera = Camera.main;
        }
    }