Пример #1
0
    // Update is called once per frame
    void Update()
    {
        y += 0.05f;
        this.transform.Translate(new Vector3(Random.Range(1f, 3f), Mathf.Sin(y) / 5f, 0) * Random.Range(3f, 5f) * Time.deltaTime);
        //this.transform.Translate(new Vector3(Random.Range(1f, 2f), Random.Range(0.1f, 0.2f) * Time.deltaTime));

        if (this.transform.position.x > MGFoundtion.pixelToWroldPoint(MGGlobalDataCenter.defaultCenter().pixelWidth, 0).x)
        {
            Destroy(this.gameObject);
        }
    }
    void Awake()
    {
        Camera             camera         = GameObject.Find("Main Camera").GetComponent <Camera>();
        MGGlobalDataCenter singleInstance = MGGlobalDataCenter.defaultCenter();

        singleInstance.pixelHight = camera.pixelHeight;
        singleInstance.pixelWidth = camera.pixelWidth;
        Vector3 rightTopPos   = MGFoundtion.pixelToWroldPoint(singleInstance.pixelWidth, singleInstance.pixelHight);
        Vector3 leftBottomPos = MGFoundtion.pixelToWroldPoint(0, 0);

        singleInstance.leftBottomPos = leftBottomPos;
        singleInstance.rightTopPos   = rightTopPos;

        singleInstance.screenBottomY = leftBottomPos.y;
        singleInstance.screenTopY    = -1 * singleInstance.screenBottomY;
        singleInstance.screenLiftX   = leftBottomPos.x;
        singleInstance.screenRightX  = -1 * singleInstance.screenLiftX;

        Vector3 pos = MGFoundtion.pixelToWroldPoint(88f, 88f);

        singleInstance.NGUI_ButtonWidth = (pos.x - singleInstance.screenLiftX) * MGGlobalDataCenter.defaultCenter().UIScale;
    }