public static void AutoFlipPage(int pageNumber, BookPro book, float duration, FlipMode mode, Action OnComplete) { book.targetPageNumber = pageNumber; HomePageFlipper flipper = book.GetComponent <HomePageFlipper>(); if (!flipper) { flipper = book.gameObject.AddComponent <HomePageFlipper>(); } flipper.enabled = true; flipper.book = book; flipper.isFlipping = true; flipper.duration = duration - Time.deltaTime; flipper.finish = OnComplete; flipper.xc = (book.EndBottomLeft.x + book.EndBottomRight.x) / 2; flipper.pageWidth = (book.EndBottomRight.x - book.EndBottomLeft.x) / 2; flipper.pageHeight = Mathf.Abs(book.EndBottomRight.y); flipper.flipMode = mode; flipper.elapsedTime = 0; float x; if (mode == FlipMode.RightToLeft) { x = flipper.xc + (flipper.pageWidth * 0.99f); float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc); book.AutoDragRightPageToPoint(new Vector3(x, y, 0)); } else { x = flipper.xc - (flipper.pageWidth * 0.99f); float y = (-flipper.pageHeight / (flipper.pageWidth * flipper.pageWidth)) * (x - flipper.xc) * (x - flipper.xc); book.AutoDragLeftPageToPoint(new Vector3(x, y, 0)); } }
private void DrawNavigationPanel() { BookPro book = target as BookPro; #if UNITY_5_3_OR_NEWER EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); #else EditorGUILayout.BeginHorizontal(EditorStyles.textArea); #endif GUILayout.Label(new GUIContent("当前 页", "代表本书右侧的当前论文。 如果要显示最后一篇论文的后页,可以使用上一篇论文的索引+ 1设置该值")); if (GUILayout.Button("|<")) { book.CurrentPaper = 0; } if (GUILayout.Button("<")) { book.CurrentPaper--; } book.CurrentPaper = EditorGUILayout.IntField(book.CurrentPaper, GUILayout.Width(30)); EditorUtility.SetDirty(book); Undo.RecordObject(book, "CurrentPageChange"); if (GUILayout.Button(">")) { book.CurrentPaper++; } if (GUILayout.Button(">|")) { book.CurrentPaper = book.papers.Length; } EditorGUILayout.EndHorizontal(); }
private void DrawNavigationPanel() { BookPro book = target as BookPro; #if UNITY_5_3_OR_NEWER EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); #else EditorGUILayout.BeginHorizontal(EditorStyles.textArea); #endif GUILayout.Label(new GUIContent("Current Paper", "represent current paper on the right side of the book. if you want to show the back page of the last paper you may set this value with the index of last paper + 1")); if (GUILayout.Button("|<")) { book.CurrentPaper = 0; } if (GUILayout.Button("<")) { book.CurrentPaper--; } book.CurrentPaper = EditorGUILayout.IntField(book.CurrentPaper, GUILayout.Width(30)); EditorUtility.SetDirty(book); Undo.RecordObject(book, "CurrentPageChange"); if (GUILayout.Button(">")) { book.CurrentPaper++; } if (GUILayout.Button(">|")) { book.CurrentPaper = book.papers.Length; } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); list.DoLayoutList(); serializedObject.ApplyModifiedProperties(); DrawNavigationPanel(); DrawFlippingPapersRange(); if (GUILayout.Button("Update Pages Order")) { (target as BookPro).UpdatePages(); } if (GUILayout.Button("Update Pages Names")) { if (EditorUtility.DisplayDialog("Warning!", "All Pages will be renamed according to its order", "Ok", "Cancel")) { BookPro book = target as BookPro; for (int i = 0; i < book.papers.Length; i++) { book.papers[i].Front.name = "Page" + (i * 2); book.papers[i].Back.name = "Page" + (i * 2 + 1); } } } }
// Use this for initialization void Start () { if (!ControledBook) ControledBook = GetComponent<BookPro>(); //ControledBook.interactable = false; if (AutoStartFlip) StartFlipping(); }
private void DrawElement(Rect rect, int index, bool isActive, bool isFocused) { BookPro book = target as BookPro; var serialzedpaper = list.serializedProperty.GetArrayElementAtIndex(index); rect.y += 2; GUIStyle style = new GUIStyle(); EditorGUI.DrawRect(new Rect(rect.x, rect.y, rect.width, rect.height - 6), new Color(0.8f, 0.8f, 0.8f)); EditorGUI.LabelField(new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight), "Paper#" + index); if (index == book.CurrentPaper) { EditorGUI.DrawRect(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, 140, EditorGUIUtility.singleLineHeight), new Color(1, 0.3f, 0.3f)); } EditorGUI.LabelField(new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight, 40, EditorGUIUtility.singleLineHeight), "Front:"); EditorGUI.PropertyField( new Rect(rect.x + 40, rect.y + EditorGUIUtility.singleLineHeight, 100, EditorGUIUtility.singleLineHeight), serialzedpaper.FindPropertyRelative("Front"), GUIContent.none); if (index == book.CurrentPaper - 1) { EditorGUI.DrawRect(new Rect(rect.x, rect.y + 3 * EditorGUIUtility.singleLineHeight, 140, EditorGUIUtility.singleLineHeight), new Color(1, 0.3f, 0.3f)); } EditorGUI.LabelField(new Rect(rect.x, rect.y + 3 * EditorGUIUtility.singleLineHeight, 35, EditorGUIUtility.singleLineHeight), "Back:"); EditorGUI.PropertyField( new Rect(rect.x + 40, rect.y + 3 * EditorGUIUtility.singleLineHeight, 100, EditorGUIUtility.singleLineHeight), serialzedpaper.FindPropertyRelative("Back"), GUIContent.none); style.padding = new RectOffset(2, 2, 2, 2); if (GUI.Button(new Rect(rect.x + 70, rect.y + 2 * EditorGUIUtility.singleLineHeight, 20, EditorGUIUtility.singleLineHeight), tex, GUIStyle.none)) { Debug.Log("Clicked at index:" + index); Paper paper = book.papers[index]; GameObject temp = paper.Back; paper.Back = paper.Front; paper.Front = temp; } if (GUI.Button(new Rect(rect.x + 150, rect.y + EditorGUIUtility.singleLineHeight, 80, (int)(1.5 * EditorGUIUtility.singleLineHeight)), "Show")) { Paper paper = book.papers[index]; BookUtility.ShowPage(paper.Back); paper.Back.transform.SetAsLastSibling(); BookUtility.ShowPage(paper.Front); paper.Front.transform.SetAsLastSibling(); book.LeftPageShadow.gameObject.SetActive(false); book.LeftPageShadow.transform.SetParent(book.transform); book.RightPageShadow.gameObject.SetActive(false); book.RightPageShadow.transform.SetParent(book.transform); } if (GUI.Button(new Rect(rect.x + 150, rect.y + (int)(2.5 * EditorGUIUtility.singleLineHeight), 80, (int)(1.5 * EditorGUIUtility.singleLineHeight)), "Set Current")) { book.CurrentPaper = index; } }
// Use this for initialization void Start() { if (!ControledBook) { ControledBook = GetComponent <BookPro>(); } ControledBook.interactable = false; if (AutoStartFlip) { StartFlipping(); } ControledBook.OnFlip.AddListener(new UnityEngine.Events.UnityAction(PageFlipped)); }
private void OnEnable() { tex = AssetDatabase.LoadAssetAtPath("Assets\\Book-Page Curl\\Editor\\replace.png", typeof(Texture)) as Texture; if (tex == null) { tex = Texture2D.blackTexture; } list = new ReorderableList(serializedObject, serializedObject.FindProperty("papers"), true, true, true, true); list.elementHeight = 75; list.drawElementCallback = DrawElement; list.drawHeaderCallback = drawHeader; list.onAddCallback = addElement; list.onCanRemoveCallback = canremove; list.onRemoveCallback = (ReorderableList l) => { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete this Paper?\r\nThe paper pages (front and back) will be deleted from the scene", "Yes", "No")) { BookPro book = target as BookPro; if (book.EndFlippingPaper == book.papers.Count - 1) { book.EndFlippingPaper--; } OnInspectorGUI(); Paper paper = book.papers[l.index]; book.LeftPageShadow.gameObject.SetActive(false); book.LeftPageShadow.transform.SetParent(book.transform); book.RightPageShadow.gameObject.SetActive(false); book.RightPageShadow.transform.SetParent(book.transform); if (paper.Back != null) { Undo.DestroyObjectImmediate(paper.Back); } if (paper.Front != null) { Undo.DestroyObjectImmediate(paper.Front); } ReorderableList.defaultBehaviours.DoRemoveButton(l); EditorUtility.SetDirty(book); } }; }
private void addElement(ReorderableList list) { BookPro book = target as BookPro; if (book.EndFlippingPaper == book.papers.Length - 1) { book.EndFlippingPaper = book.papers.Length; OnInspectorGUI(); } list.serializedProperty.arraySize++; var lastElement = list.serializedProperty.GetArrayElementAtIndex(list.count - 1); GameObject rightPage = Instantiate(book.RightPageTransform.gameObject) as GameObject; rightPage.transform.SetParent(book.transform, true); rightPage.GetComponent <RectTransform>().sizeDelta = book.RightPageTransform.GetComponent <RectTransform>().sizeDelta; rightPage.GetComponent <RectTransform>().pivot = book.RightPageTransform.GetComponent <RectTransform>().pivot; rightPage.GetComponent <RectTransform>().anchoredPosition = book.RightPageTransform.GetComponent <RectTransform>().anchoredPosition; rightPage.GetComponent <RectTransform>().localScale = book.RightPageTransform.GetComponent <RectTransform>().localScale; rightPage.name = "Page" + ((list.serializedProperty.arraySize - 1) * 2); rightPage.AddComponent <Image>(); rightPage.AddComponent <Mask>().showMaskGraphic = true; rightPage.AddComponent <CanvasGroup>(); lastElement.FindPropertyRelative("Front").objectReferenceInstanceIDValue = rightPage.GetInstanceID(); GameObject leftPage = Instantiate(book.LeftPageTransform.gameObject) as GameObject; leftPage.transform.SetParent(book.transform, true); leftPage.GetComponent <RectTransform>().sizeDelta = book.LeftPageTransform.GetComponent <RectTransform>().sizeDelta; leftPage.GetComponent <RectTransform>().pivot = book.LeftPageTransform.GetComponent <RectTransform>().pivot; leftPage.GetComponent <RectTransform>().anchoredPosition = book.LeftPageTransform.GetComponent <RectTransform>().anchoredPosition; leftPage.GetComponent <RectTransform>().localScale = book.LeftPageTransform.GetComponent <RectTransform>().localScale; leftPage.name = "Page" + ((list.serializedProperty.arraySize - 1) * 2 + 1); leftPage.AddComponent <Image>(); leftPage.AddComponent <Mask>().showMaskGraphic = true; leftPage.AddComponent <CanvasGroup>(); lastElement.FindPropertyRelative("Back").objectReferenceInstanceIDValue = leftPage.GetInstanceID(); list.index = list.count - 1; Undo.RegisterCreatedObjectUndo(leftPage, ""); Undo.RegisterCreatedObjectUndo(rightPage, ""); }
/// <summary> /// 得到UI组件 /// </summary> protected override void GetUIComponent() { base.GetUIComponent(); Button_Close = GetUI <Button>("Button_Close"); Button_Catalog = GetUI <Button>("Button_Catalog"); BookPro = GetUI <BookPro>("BookPro"); AutoFlip = GetUI <AutoFlip>("BookPro"); FirstPage = GetUI <UIPageItem>("FirstPage"); Button_LeftPage = GetUI <Button>("Button_LeftPage"); Button_RigthPage = GetUI <Button>("Button_RigthPage"); Toggle_CatalogPeople = GetUI <Toggle>("Toggle_CatalogPeople"); Toggle_CatalogThing = GetUI <Toggle>("Toggle_CatalogThing"); Toggle_CatalogRecord = GetUI <Toggle>("Toggle_CatalogRecord"); Panel_Catalog = GetUI <CanvasGroup>("Panel_Catalog"); }
void Start() { player = GameObject.FindGameObjectWithTag("Player"); start_pos = GameObject.Find("Start_Pos"); dragging = diary.GetComponent <BookPro>(); ti = GameObject.FindWithTag("Dialogue").GetComponent <Text_Importer2>(); ti.Import(61); on_off = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(0).gameObject; itemButton0 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(0).GetComponent <Image>(); item0 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(0).GetChild(0).GetComponent <Image>(); itemButton1 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(1).GetComponent <Image>(); item1 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(1).GetChild(1).GetComponent <Image>(); itemButton2 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(2).GetComponent <Image>(); itemButton3 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(3).GetComponent <Image>(); itemButton4 = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(0).GetChild(1).GetChild(4).GetComponent <Image>(); joystick = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(3).gameObject; jumpButton = GameObject.FindGameObjectWithTag("Item_Canvas").transform.GetChild(1).gameObject; on_off.SetActive(false); joystick.SetActive(false); jumpButton.SetActive(false); itemButton0.enabled = false; item0.enabled = false; itemButton1.enabled = false; item1.enabled = false; itemButton2.enabled = false; itemButton3.enabled = false; itemButton4.enabled = false; player.transform.position = start_pos.transform.position; if (!Stage6_Controller.q[15]) { ti.Talk(); } else if (!Stage6_Controller.q[25]) { ti.Talk(4); // 음 여긴 없는걸 } else if (!Stage6_Controller.q[35]) { dragging.CurrentPaper = 5; } else if (!Stage6_Controller.q[42]) { dragging.CurrentPaper = 3; ti.Talk(10); // 여기서 갑자기 왜 일기장을..? } }
// Start is called before the first frame update void Start() { if (SceneManager.GetActiveScene().name == "UIScene") { bookPro = GameObject.Find("Canvas/ChooseLevelPanel/BookPro").GetComponent <BookPro>(); soundEffectsInBegin = GameObject.FindWithTag("GameController").GetComponent <SoundEffectsInBegin>(); AudioSource = GameObject.FindWithTag("GameController").GetComponent <AudioSource>(); text1 = GameObject.Find("HintText2").GetComponent <Text>(); text2 = GameObject.Find("HintText3").GetComponent <Text>(); button = GameObject.Find("Exit"); } if (SceneManager.GetActiveScene().name == "StoryMode") { alert = GameObject.Find("Alert").GetComponent <Text>(); alert.DOFade(1, 0.1f); StartCoroutine(AlertShow()); } }
private void DrawFlippingPapersRange() { BookPro book = target as BookPro; #if UNITY_5_3_OR_NEWER EditorGUILayout.BeginVertical(EditorStyles.helpBox); #else EditorGUILayout.BeginVertical(EditorStyles.textArea); #endif EditorGUILayout.LabelField("Flipping Range", EditorStyles.boldLabel); EditorGUILayout.LabelField("First Flippable Paper: " + "Paper#" + book.StartFlippingPaper); EditorGUILayout.LabelField("Last Flippable Paper: " + "Paper#" + book.EndFlippingPaper); float start = book.StartFlippingPaper; float end = book.EndFlippingPaper; EditorGUILayout.MinMaxSlider(ref start, ref end, 0, book.papers.Length - 1); book.StartFlippingPaper = Mathf.RoundToInt(start); book.EndFlippingPaper = Mathf.RoundToInt(end); EditorGUILayout.EndVertical(); }
public void AddPaper(BookPro book) { GameObject frontPage = Instantiate(FrontPagePrefab); GameObject backPage = Instantiate(BackPagePrefab); frontPage.transform.SetParent(book.transform, false); backPage.transform.SetParent(book.transform, false); Paper newPaper = new Paper(); newPaper.Front = frontPage; newPaper.Back = backPage; Paper[] papers = new Paper[book.papers.Length + 1]; for (int i = 0; i < book.papers.Length; i++) { papers[i] = book.papers[i]; } papers[papers.Length - 1] = newPaper; book.papers = papers; //update the flipping range to contain the new added paper book.EndFlippingPaper = book.papers.Length - 1; book.UpdatePages(); }
private void Init() { if (book != null) { return; } book = mTransform.Find("BookPro").gameObject.AddComponent <BookPro>(); menuPrefab = mTransform.Find("BookPro/MenuPrefab").gameObject.AddComponent <MenuParts>(); mTransform.Find("BookPro/LeftPage").gameObject.AddComponent <MenuParts>(); mTransform.Find("BookPro/RightPage").gameObject.AddComponent <MenuParts>(); eventBox = mTransform.Find("EventBox").gameObject; preButton = mTransform.Find("EventBox/PreButton").GetComponent <Button>(); nextButton = mTransform.Find("EventBox/NextButton").GetComponent <Button>(); toTopButton = mTransform.Find("EventBox/BackButton").GetComponent <Button>(); autoButton = mTransform.Find("EventBox/AutoButton").GetComponent <Button>(); frontCover = mTransform.Find("BGBox/Front_Cover").GetComponent <RawImage>(); backCover = mTransform.Find("BGBox/Back_Cover").GetComponent <RawImage>(); progressBox = mTransform.Find("Progress_Box").gameObject; progressSlider = mTransform.Find("Progress_Box").GetComponentInChildren <Slider>(); videoPlayer = mTransform.Find("VideoPlayer").GetComponent <VideoPlayer>(); videoBox = mTransform.Find("VideoPlayer/VideoBox").GetComponent <RectTransform>(); videoRender = mTransform.Find("VideoPlayer/VideoBox/RenderImage").GetComponent <RectTransform>(); videoTools = mTransform.Find("VideoPlayer/VideoBar").gameObject.AddComponent <VideoBarParts>(); }
private void Awake() { Book = GetComponent <BookPro>(); }