You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used this code to try to view the slice in Image Component
I tried to use the same method from SliceRenderingEditorWindow but it didn't work
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;namespaceUnityVolumeRendering{publicclassSliceImage:MonoBehaviour{privateSlicingPlane[]spawnedPlanes;privateImagesliceImage;// Start is called before the first frame updatevoidStart(){}// Update is called once per framevoidUpdate(){spawnedPlanes=FindObjectsOfType<SlicingPlane>();varsliceImageParent=this.gameObject.transform.GetChild(0).gameObject.transform.GetChild(0).gameObject.transform.GetChild(2).gameObject;Debug.Log("Parent name: "+sliceImageParent.name);sliceImage=sliceImageParent.GetComponent<Image>();if(sliceImage==null){Debug.LogError("No Image component found in children of this object");}else{Debug.Log("Image component found");Debug.Log("Image component name: "+sliceImage.name);}if(spawnedPlanes.Length>0){SlicingPlaneplaneObj=spawnedPlanes[0];Materialmat=planeObj.GetComponent<MeshRenderer>().sharedMaterial;Texture3Dtex3D=mat.GetTexture("_DataTex")asTexture3D;// Create a new Texture2D with the same format as the Texture3DTexture2Dtex2D=newTexture2D(tex3D.width,ex3D.height,tex3D.format,tex3D.mipmapCount>1);// Copy the slice from the 3D texture to the 2D textureGraphics.CopyTexture(tex3D,0,0,tex2D,0,0);sliceImage.sprite=Sprite.Create(tex2D,newRect(0,0,tex2D.width,tex2D.height),newVector2(0.5f,0.5f));}}}}
The text was updated successfully, but these errors were encountered:
I used this code to try to view the slice in Image Component
I tried to use the same method from
SliceRenderingEditorWindow
but it didn't workThe text was updated successfully, but these errors were encountered: