예제 #1
0
    void ProcessSelected(Vector2 position)
    {
        int telescopeLayers = 1 << LayerMask.NameToLayer("TelescopePins");

        // The ray to the touched object in the world
        Ray ray = Camera.main.ScreenPointToRay(position);

        // Your raycast handling
        RaycastHit vHit;

        Debug.DrawRay(ray.origin, 10 * ray.direction, Color.yellow);
        if (Physics.Raycast(ray, out vHit, Mathf.Infinity, telescopeLayers))
        {
            if (vHit.transform.tag == "TelescopePin")
            {
                // GameObject Telescope_Container = GameObject.FindWithTag("Earth");
                // GameObject Telescope_Container = GameObject.Find("Earth_NewModel2");
                Load_TelescopeData script = GetComponent <Load_TelescopeData>();

                GameObject Selected_Telescope = vHit.transform.gameObject;
                PinScript  script_2           = Selected_Telescope.GetComponent <PinScript>();

                script.Select_Telescope(script_2.ID);
            }
        }
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        Transform TelescopeContainer = transform.Find("TelescopePinContainer");
        int       NumberofPins       = positionArray.Length;

        CurrentTelescopes = new GameObject[NumberofPins];

        for (int i = 0; i < NumberofPins; i++)
        {
            float      x = positionArray[i].x;
            float      y = positionArray[i].y;
            float      z = positionArray[i].z;
            Vector3    Telescope_pin_location = new Vector3(x, z, y).normalized *distance;
            GameObject pinObject = Instantiate(Pin_object, new Vector3(0, 0, 0), Quaternion.identity);
            pinObject.layer                   = LayerMask.NameToLayer("TelescopePins"); // Telescope Pins layer is 9
            pinObject.transform.parent        = TelescopeContainer;
            pinObject.transform.localPosition = Telescope_pin_location;
            PinScript pinScript = pinObject.AddComponent <PinScript>();

            pinScript.ID            = i;
            pinObject.transform.tag = "TelescopePin";

            pinObject.transform.Rotate(rotationArray[i], Space.Self);

            pinObject.name       = Tel_Names[i];
            CurrentTelescopes[i] = pinObject;
        }
        Select_Telescope(-1);
    }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        //StreamReader inp_stm = new StreamReader(".\\Assets\\Earth\\Materials\\Materials\\Telescope_Coordinates\\Data.txt");
        Transform TelescopeContainer = transform.Find("TelescopePinContainer");
        //while (!inp_stm.EndOfStream)
        int array_index  = 0;
        int NumberofPins = 8;

        CurrentTelescopes = new GameObject[NumberofPins];
        while (array_index <= NumberofPins - 1)
        {
            //string inp_ln = inp_stm.ReadLine();
            //string[] splited = inp_ln.Split(' ');


            //float x = float.Parse(splited[1]);
            //float y = float.Parse(splited[2]);
            // float z = float.Parse(splited[3]);
            float   x = positionArray[array_index].x;
            float   y = positionArray[array_index].y;
            float   z = positionArray[array_index].z;
            Vector3 Telescope_pin_location = new Vector3(x, z, y);
            Telescope_pin_location = Telescope_pin_location.normalized * distance;

            //Instantiate(Telescope_Prefab, Telescope_pin_location, new Quaternion(0, 0, 0, 0),);
            GameObject sphere = Instantiate(Pin_object, new Vector3(0, 0, 0), Quaternion.identity);
            //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            sphere.layer                   = LayerMask.NameToLayer("TelescopePins"); // Telescope Pins layer is 9
            sphere.transform.parent        = TelescopeContainer;
            sphere.transform.localPosition = Telescope_pin_location;
            PinScript   p  = sphere.AddComponent <PinScript>();
            BoxCollider sc = sphere.AddComponent <BoxCollider>();

            p.ID = array_index;
            sphere.transform.tag = "TelescopePin";


            //Vector3 normalVector = sphere.transform.localPosition;
            //float size = normalVector.magnitude;

            sphere.transform.Rotate(rotationArray[array_index], Space.Self);

            //sphere.transform.localScale = new Vector3(1, 1, 1) * scale_;
            //sphere.name = splited[0];
            sphere.name = Tel_Names[array_index];
            CurrentTelescopes[array_index] = sphere;
            array_index++;
        }

        this.Select_Telescope(-1);
        //inp_stm.Close();
    }
예제 #4
0
    void ProcessSelected(Vector2 position)
    {
        int telescopeLayers = 1 << LayerMask.NameToLayer("TelescopePins");

        // The ray to the touched object in the world
        Ray ray = Camera.main.ScreenPointToRay(position);

        // Your raycast handling
        RaycastHit vHit;

        Debug.DrawRay(ray.origin, 10 * ray.direction, Color.yellow);
        if (Physics.Raycast(ray, out vHit, Mathf.Infinity, telescopeLayers))
        {
            if (vHit.transform.tag == "TelescopePin")
            {
                GameObject Selected_Telescope = vHit.transform.gameObject;
                pinScript = Selected_Telescope.GetComponent <PinScript>();

                LoadTelescope.Select_Telescope(pinScript.ID);
            }
        }
    }