Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Image control and Plane

Discussion in 'Scripting' started by game4tress, May 19, 2015.

  1. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    I want to place a plane uppon an image control. The plane must be placed in the same x and y coordinates and have the same width and height.
    I've made a test (that I place bellow), but doen't work. The plane is not being placed on the same location as the image control, and I also didn't find a way to resize the plane to the same with as the Image control.
    Is this possible? How?
    My thanks in advanced.


    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;


    public class Script_TestResize : MonoBehaviour {

    private GameObject objPlaneTest;
    private GameObject objImageTest;


    private Plane PlaneTest;

    private Image Imagetest;

    // Use this for initialization
    void Start () {

    RectTransform.Axis AXH;
    RectTransform.Axis AXV;

    objPlaneTest=GameObject.Find("PlaneTest");
    objImageTest=GameObject.Find("ImageTest");


    objPlaneTest.transform.position=objImageTest.transform.position;




    Imagetest=GameObject.Find("ImageTest").GetComponent<Image>();


    AXH=RectTransform.Axis.Horizontal;
    AXV=RectTransform.Axis.Vertical;

    Imagetest.rectTransform.SetSizeWithCurrentAnchors(AXH,60.00F);
    Imagetest.rectTransform.SetSizeWithCurrentAnchors(AXV,90.00F);


    objPlaneTest.transform.position=objImageTest.transform.position;//new Vector3(objImageTest.transform.position.x,objImageTest.transform.position.y,0);​

    }

    // Update is called once per frame
    void Update () {

    }​
    }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    why?


    also [ code] [ /code] tags (without spaces) will save you a lot of time indenting lines....
     
  3. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    Well, because I need to "import" an image (and other things, like points), from another software I developed in WPF, into Unity. The size of the image is only known when the user presses the button (and Unity opens). Then I need to draw the image, with the points and Bezier curves on the right place in the image. It's like importing everything in order to use the 3D features of Unity.

    (Thanks for the tip)