Inheritance: MonoBehaviour
Beispiel #1
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Beispiel #2
0
    void Start()
    {
        closeButton.onClick.AddListener(delegate()
        {
            Destroy(gameObject);
        });

        panel.gameObject.SetActive(false);
        m_Flip = m_Book.GetComponent <AutoFlip>();
    }
Beispiel #3
0
 private void InitAutoFlipCheckBoxes(AutoFlip flip)
 {
     _autoFlipVert        = (flip & AutoFlip.VertFlip) != 0;
     _autoFlipHorz        = (flip & AutoFlip.HorzFlip) != 0;
     _autoFlipVertHorz    = (flip & AutoFlip.BothFlip) != 0;
     _autoRotateLeft      = (flip & AutoFlip.RotateLeft) != 0;
     _autoRotateLeftFlip  = (flip & AutoFlip.LeftHorzFlip) != 0;
     _autoRotateRight     = (flip & AutoFlip.RotateRight) != 0;
     _autoRotateRightFlip = (flip & AutoFlip.RightHorzFlip) != 0;
 }
    void Start()
    {
        closeButton.onClick.AddListener(delegate()
        {
            panel.gameObject.SetActive(false);
        });

        panel.gameObject.SetActive(false);
        m_Flip = m_Book.GetComponent <AutoFlip>();

        openBtn.onClick.AddListener(ShowBook);

        pdfViewr = GetComponent <PdfViewer>();

        InitBook();
    }
Beispiel #5
0
    /// <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");
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        if (!ControledBook)
        {
            ControledBook = GetComponent <Book>();
        }
        if (AutoStartFlip)
        {
            StartFlipping();
        }
        ControledBook.OnFlip.AddListener(new UnityEngine.Events.UnityAction(PageFlipped));
    }
Beispiel #7
0
 public void Awake()
 {
     autoFlip = GameObject.Find("Book").GetComponent <AutoFlip>();
     print(autoFlip);
 }
Beispiel #8
0
    public void LoadGame()
    {
        isgameready = true;
        btnshow();
        GameObject tempObj;
        Vector2    pos;

        // define center position
        center   = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane));
        showHint = false;
        // Instantiate parent object for other game objects
        parentObj = Instantiate(parentObject, transform.position, Quaternion.identity) as GameObject;
        // randomize the words in our list...
        //Shuffle(words);
        // ...pick one word...

        mDiaryflip = Dairy_book[wordcount].GetComponent <AutoFlip>();
        word       = words[wordcount++];//words[UnityEngine.Random.Range(0, words.Length)];
        // ...and split to the array
        _word = word.ToCharArray();
        Shuffle(_word);
        // spacing between tiles can never be below 1
        spacing = Mathf.Clamp(spacing, 1, float.MaxValue);

        // center field elements as much as possible
        bool left = false;
        int  leftv = 0, rightv = 1;
        Dictionary <GameObject, float> fields = new Dictionary <GameObject, float>();

        for (int i = 0; i < _word.Length; i++)
        {
            left = !left;
            if (left)
            {
                tempObj = Instantiate(letterHolder, Camera.main.ScreenToWorldPoint(new Vector3(((Screen.width / 2)) - (leftv * Screen.width / 24 * letterHolder.transform.localScale.x * spacing), center.y + Screen.height / 8, 200)), Quaternion.identity) as GameObject;
                leftv++;
            }
            else
            {
                tempObj = Instantiate(letterHolder, Camera.main.ScreenToWorldPoint(new Vector3(((Screen.width / 2)) + (rightv * Screen.width / 24 * letterHolder.transform.localScale.x * spacing), center.y + Screen.height / 8, 200)), Quaternion.identity) as GameObject;
                rightv++;
            }
            fields.Add(tempObj, tempObj.transform.position.x);
        }

        // sort field elements
        fields = fields.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        leftv = 0;
        foreach (KeyValuePair <GameObject, float> targ in fields)
        {
            targ.Key.GetComponent <HolderValue>().SetOrder(leftv);
            targ.Key.name             = holderName + leftv.ToString();
            targ.Key.transform.parent = parentObj.transform;
            Vector3 p = Camera.main.WorldToScreenPoint(targ.Key.transform.position);
            leftv++;
        }

        tempValues = new string[_word.Length];

        // finnaly, instantiate letters
        for (int i = 0; i < _word.Length; i++)
        {
            pos     = new Vector2(UnityEngine.Random.Range(Screen.width / 6 + i * (Screen.width * 2 / 3 / _word.Length) + Screen.width / 20, Screen.width * 5 / 6 - (_word.Length - i - 1) * (Screen.width * 2 / 3 / _word.Length) - Screen.width / 20), UnityEngine.Random.Range(Screen.height * 5 / 6, Screen.height / 2));
            tempObj = Instantiate(letterTile, Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, 10)), Quaternion.identity) as GameObject;
            tempObj.GetComponent <LetterValue>().SetValue(_word[i].ToString());
            tempObj.name             = tileName + i.ToString();
            tempObj.transform.parent = parentObj.transform;
            if (rotateTiles)
            {
                tempObj.transform.eulerAngles = new Vector3(0, UnityEngine.Random.Range(0, 360), 0);
            }
        }
    }