Exemplo n.º 1
0
 void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Exemplo n.º 2
0
        void Awake()
        {
            if (Instance != null)
            {
                Destroy(this);
                throw new InvalidOperationException("A Converter component has already been instantiated");
            }

            Instance = this;
        }
Exemplo n.º 3
0
        public static GameObject ToNative(this SpeckleCore.SpecklePolyline specklePolyline)
        {
            GameObject go = SpecklePrefabs.InstantiateLine();

            go.GetComponent <UnitySpeckleObjectData>().Id            = specklePolyline._id;
            go.GetComponent <UnitySpeckleObjectData>().SpeckleObject = specklePolyline;

            Vector3[] pts = Util.SpecklePointsToUnityPoints(specklePolyline.Value);
            go.GetComponent <LineRenderer>().positionCount = pts.Length;
            go.GetComponent <LineRenderer>().SetPositions(pts);

            return(go);
        }
Exemplo n.º 4
0
        public static GameObject ToNative(this SpeckleCore.SpecklePoint specklePoint)
        {
            GameObject go = SpecklePrefabs.InstantiatePoint();

            go.GetComponent <UnitySpeckleObjectData>().Id            = specklePoint._id;
            go.GetComponent <UnitySpeckleObjectData>().SpeckleObject = specklePoint;

            Vector3 unityPoint = Util.SpecklePointsToUnityPoints(specklePoint.Value)[0];

            Vector3[] pts = new Vector3[] { unityPoint, unityPoint };
            go.GetComponent <LineRenderer>().positionCount = pts.Length;
            go.GetComponent <LineRenderer>().SetPositions(pts);

            return(go);
        }
        public static GameObject ToNative(this SpeckleCore.SpeckleMesh speckleMesh)
        {
            GameObject go = SpecklePrefabs.InstantiateMesh();

            go.GetComponent <UnitySpeckleObjectData>().Id            = speckleMesh._id;
            go.GetComponent <UnitySpeckleObjectData>().SpeckleObject = speckleMesh;

            Mesh unityMesh = go.GetComponent <MeshFilter>().mesh;

            unityMesh.vertices  = Util.SpecklePointsToUnityPoints(speckleMesh.Vertices);
            unityMesh.triangles = Util.SpeckleFacesToUnityTriangles(speckleMesh.Faces);

            unityMesh.RecalculateNormals();
            unityMesh.RecalculateTangents();

            MeshCollider mc = go.AddComponent <MeshCollider>();

            mc.sharedMesh = unityMesh;

            return(go);
        }