private static bool TryHandleState( State state, string folderPath, out Exported.State exportedState) { exportedState = default; TextureSource textureSource = state.GetComponent <TextureSource>(); if (textureSource == null) { EditorUtility.DisplayDialog("Error", "State has no texture source!", "Ok"); return(false); } var stateId = state.GetExportedId(); exportedState = new Exported.State { id = stateId, title = state.title, url = $"{Tour.Instance.linkPrefix}{textureSource.Export(folderPath, stateId)}", type = textureSource.SourceType.ToString().ToLower(), pictureRotation = state.transform.rotation, links = GetLinks(state), groupLinks = GetGroupLinks(state) }; return(true); }
private static bool TryHandleState( State state, string folderPath, ResourceHandlePath resourceHandlePath, int imageCroppingLevel, out Exported.State exportedState) { exportedState = default; TextureSource textureSource = state.GetComponent<TextureSource>(); if (textureSource == null) { EditorUtility.DisplayDialog("Error", "State has no texture source!", "Ok"); return false; } var stateId = state.GetExportedId(); var textureFileLocation = textureSource.GetAssetPath(); string url = null; string croppedImageUrl = null; switch (resourceHandlePath) { case ResourceHandlePath.CopyToDist: var stateFolderPath = Path.Combine(folderPath, stateId); ImageCropper.HandleImage(textureFileLocation, stateFolderPath, imageCroppingLevel); croppedImageUrl = stateId; break; case ResourceHandlePath.PublishPath: url = textureFileLocation; if (url.StartsWith("Packages")) { EditorUtility.DisplayDialog("Error", "You can't use texture from Packages while preview. Please use textures only from Assets", "Ok"); return false; } break; default: throw new Exception($"incorrect ResourceHandlePath {resourceHandlePath}"); } exportedState = new Exported.State { id = stateId, title = state.title, url = url, croppedImageUrl = croppedImageUrl, type = textureSource.SourceType.ToString().ToLower(), pictureRotation = state.transform.rotation, links = GetLinks(state), groupLinks = GetGroupLinks(state), fieldItems = GetFieldItems(state, folderPath, resourceHandlePath) }; return true; }