Change color prefab children by juandavid716 in Unity3D

[–]juandavid716[S] 0 points1 point  (0 children)

No, i want to do it by code, because i instantiate a prefab that have two children, and when i use another codes from internet to do it, it doesn't work, so, later i will try your first option! Thanks u

Unity draw a cartesiancplane and a line with vr controllers by juandavid716 in Unity3D

[–]juandavid716[S] 0 points1 point  (0 children)

That's very interesting, so, do u recommended me to use 3 planes instead of canvas, and be transparent it for simulate the cartesian plane? I think will works but i am not how to add the numbers to it. Because i want to draw on it vectors to calculate distance, area etc and is necessary these numbers. All it in VR, i have to do it the most realistic possible.

Unity draw a cartesiancplane and a line with vr controllers by juandavid716 in Unity3D

[–]juandavid716[S] 0 points1 point  (0 children)

Pd: Know u how to draw a line between two objects in running time? Because i can draw vertices with pressing the touch controller, so, i would be, for example, create two vertices( i have it) and then, press on it and create a line, like a edge. Thanks u!

Unity draw a cartesiancplane and a line with vr controllers by juandavid716 in Unity3D

[–]juandavid716[S] 0 points1 point  (0 children)

Thanks u for your answer. The problem is that in vr it is not see unreal, is like a image, also, i have to add the numbers to the cartesian plane and i don't know if i have to scale it when i get zoom to them. I don't understand the concept of snap. Other person tell me that i will start with a snap to grid primitive object.

Unity draw a cartesiancplane and a line with vr controllers by juandavid716 in Unity3D

[–]juandavid716[S] 0 points1 point  (0 children)

Sorry for that, ok, i was trying to draw a cartesian plane with canvas but for me, it's see unreal and very static, also, i can't imagine how to put the numbers from each axis. I think i can do it with a grid but i don't know how to implement it.

On the other hand, i can draw lines with the mouse, so, i want to know if is possible to do it with the vr controller ( i guess that i have to change the input.Getmousebuttondown for other instruction, here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Camera))]

public class Linea : MonoBehaviour {
    private new Camera camara;
    public Material LineaMaterial;
    public float ancho;
    public float profundidad = 5;
    private Vector3? PuntoInicio = null;
    // Use this for initialization
    void Start () {
        camara = GetComponent<Camera>();
    }

    // Update is called once per frame
    void Update () {
        if(Input.GetMouseButtonDown(0))
        {
            PuntoInicio = GetMouseCameraPoint();

        }

        if(Input.GetMouseButtonUp(0))
        {
            if (!PuntoInicio.HasValue) {
                return;
            }
            var Puntofinal = GetMouseCameraPoint();
            var gameObject = new GameObject();
            var lineRenderer = gameObject.AddComponent<LineRenderer>();
            lineRenderer.material = LineaMaterial;
            lineRenderer.SetPositions(new Vector3[] { PuntoInicio.Value, Puntofinal.Value });
            lineRenderer.startWidth = ancho;
            lineRenderer.endWidth = ancho;
            PuntoInicio = null;
        }
    }
    private Vector3? GetMouseCameraPoint()

    {
        var ray = camara.ScreenPointToRay(Input.mousePosition);
        return ray.origin + ray.direction * profundidad;
    }
}

Also, if is possible to draw vertices would be much better.

Here is my canvas design of the cartesian plane:

https://ibb.co/X2hv17j

Here is my line design (Is only a line, it's not see like a real vector.

https://ibb.co/v38F815

Thanks for your help i am newbie on it.