예제 #1
0
    void Initialize()
    {
        Controller = GameObject.FindGameObjectWithTag("Magic");
        CO         = Controller.GetComponent <ColorizeObjects> ();
        SC         = Controller.GetComponent <ShapeCreator> ();

        rectTrans     = gameObject.GetComponent <RectTransform> ();
        startPosition = rectTrans.localPosition;

        startParent = GameObject.FindGameObjectWithTag("Canvas");
        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);

        if (gameObject.name == "Circle")
        {
            shapeNR = 0;
        }
        else if (gameObject.name == "Triangle")
        {
            shapeNR = 1;
        }
        else
        {
            shapeNR = 2;
        }
    }
예제 #2
0
    public void SpawnRandomTestObjects()
    {
        RectTransform canvasRect = canvas.GetComponent <RectTransform> ();
        int           width      = (int)canvasRect.rect.width;
        int           height     = (int)canvasRect.rect.height;
        int           padding    = (int)Mathf.Round(Mathf.Min(width, height) * 0.2f);
        int           id         = 0;

        for (int i = 0; i < spawnNumber; i++)
        {
            int s = (int)drawShape;
            if (random)
            {
                s = Random.Range(0, 3);                    // Get random shape
            }
            float x = Random.Range(padding, width - padding) - width / 2;
            float y = Random.Range(padding, height - padding) - height / 2;
            CreateShape(s, x, y);
        }
        if (colorize)
        {
            ColorizeObjects CO = gameObject.GetComponent <ColorizeObjects> ();
            CO.ColorizeAll();
        }
    }
예제 #3
0
파일: spawnShapes.cs 프로젝트: Zihn/Shapes
    void Start()
    {
        Controller = GameObject.FindGameObjectWithTag("Magic");
        CO         = Controller.GetComponent <ColorizeObjects> ();
        SC         = Controller.GetComponent <ShapeCreator> ();
        grid       = Controller.GetComponent <SnapToGrid> ();

        rectTrans     = gameObject.GetComponent <RectTransform> ();
        startPosition = rectTrans.localPosition;

        // No need for a position shift since .position is used with screen- overlay
//		startParent = GameObject.FindGameObjectWithTag ("Canvas");
//		Rect parentRect = startParent.GetComponent<RectTransform> ().rect;
//
//		shiftPos = new Vector3 (-parentRect.width / 2, -parentRect.height / 2, 0);

        if (gameObject.GetComponent <Shape>().GetType() == typeof(Circle))
        {
            shapeNR = 0;
        }
        else if (gameObject.GetComponent <Shape>().GetType() == typeof(Triangle))
        {
            shapeNR = 1;
        }
        else
        {
            shapeNR = 2;
        }
    }
예제 #4
0
    public override void OnInspectorGUI()
    {
        ColorizeObjects CO = (ColorizeObjects)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Colorize"))
        {
            CO.ColorizeAll();
        }
    }
예제 #5
0
    void Initialize()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO          = Controller.GetComponent <ColorizeObjects> ();
        SC          = Controller.GetComponent <ShapeCreator> ();
        rectTrans   = gameObject.GetComponent <RectTransform> ();
        startParent = GameObject.FindGameObjectWithTag("Canvas");

        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);
    }
예제 #6
0
    void Start()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO        = Controller.GetComponent <ColorizeObjects> ();
        SC        = Controller.GetComponent <ShapeCreator> ();
        grid      = Controller.GetComponent <SnapToGrid> ();
        OS        = Controller.GetComponent <ObjectSelector> ();
        rectTrans = gameObject.GetComponent <RectTransform> ();

        // No need for a position shift since .position is used with screen- overlay
        startParent = GameObject.FindGameObjectWithTag("Canvas");
        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);
    }
예제 #7
0
    void Start()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO       = Controller.GetComponent <ColorizeObjects> ();
        SC       = Controller.GetComponent <ShapeCreator> ();
        grid     = Controller.GetComponent <SnapToGrid> ();
        OS       = Controller.GetComponent <ObjectSelector> ();
        material = Background.GetComponent <Shape> ().material;
        width    = Background.GetComponent <RectTransform> ().rect.width;
        height   = Background.GetComponent <RectTransform> ().rect.height;
        Debug.Log(Background.GetComponent <RectTransform> ().rect.width);
        material.SetFloat("_Width", width);
        material.SetFloat("_Height", height);
//		material.SetFloat ("_XPosition", t);
//		material.SetFloat ("_YPosition", t);
    }