/// <summary> /// Intialise un nouvel objet d'interface de maillage. /// </summary> /// <param name="meshWorkerObj_">Le travailleur du maillage.</param> /// <param name="layerWorkerObj_">Le travailleur de calques du maillage.</param> /// <param name="isReference_">Indique si l'objet est une référence.</param> public void Initialize(GameObject meshWorkerObj_, GameObject layerWorkerObj_, bool isReference_, bool isPermanent_, bool isMoveable_) { MeshWorkerObj_ = meshWorkerObj_; LayerWorkerObj_ = layerWorkerObj_; IsReference_ = isReference_; IsPermanent_ = isPermanent_; IsMoveable_ = isMoveable_; IsInitialized = true; name = $"UIObject-{transform.GetSiblingIndex():D3}"; ObjectNameObj_.GetComponent <Text>().text = $"Object-{transform.GetSiblingIndex():D3}"; SetupButton(); BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>().ForceDraw(); if (isReference_) { if (ReferenceObjectObj_ != null) { Remove(ReferenceObjectObj_); } ReferenceObjectObj_ = gameObject; var WorkerObjAFCW_ = WorkerObj_.GetComponent <AugmentedFaceCreatorWorker>(); WorkerObjAFCW_.SetupLights(meshWorkerObj_); } var bodyLandscapeObjUIBL_ = BodyLandscapeObj_.GetComponent <UIAugmentedFaceCreatorBodyLandscape>(); bodyLandscapeObjUIBL_.DrawUI += Draw; bodyLandscapeObjUIBL_.ForceDraw(); }
/// <summary> /// Ajoute une interface de calque en demandant de choisir une nouvelle texture. /// </summary> public void AddLayer(Action <Texture2D> callback_) { #if !UNITY_EDITOR if (NativeGallery.CheckPermission() != NativeGallery.Permission.Granted) { if (NativeGallery.RequestPermission() != NativeGallery.Permission.Granted && NativeGallery.CanOpenSettings()) { NativeGallery.OpenSettings(); } else { Application.Quit(); } } if (!NativeGallery.IsMediaPickerBusy()) { var workerObjAFCW_ = AugmentedFaceCreatorWorker.Instance_; var maxSize_ = Mathf.Max(workerObjAFCW_.TextureWidth_, workerObjAFCW_.TextureHeight_); NativeGallery.GetImageFromGallery((path_) => { var texture_ = NativeGallery.LoadImageAtPath(path_, maxSize: maxSize_, markTextureNonReadable: false, generateMipmaps: false); AddLayer(texture_, false, false, true); callback_?.Invoke(texture_); }, title: "Select a texture"); } #else var workerAFCW_ = WorkerObj_.GetComponent <AugmentedFaceCreatorWorker>(); var texture_ = Texture2D.whiteTexture; texture_.Resize(1024, 512); texture_.Apply(); AddLayer(texture_, false, false, true); callback_?.Invoke(texture_); #endif }