Update() public method

public Update ( ) : void
return void
    void Update()
    {
        if (Camera.main == null)
        {
            return;
        }

        Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        bool    valid         = (EventSystem.current != null && !EventSystem.current.IsPointerOverGameObject());

        for (int layerIndex = 0; layerIndex < m_Raycasters.Length; ++layerIndex)
        {
            Raycaster raycaster = m_Raycasters[layerIndex];
            raycaster.Update(mousePosition, valid);
        }
    }
示例#2
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            //If left click
            if (RenderStep != null && Raycaster != null && (Engine.Core.IsMouseClicked(0) || ConstantUpdate))
            {
                //Update
                Raycaster.Update();

                RenderStep.Models.Clear();
                Dictionary <Model, float> dictonary = Raycaster.BoundingSphere(Models);
                if (dictonary.Count > 0)
                {
                    RenderStep.Models.Add(dictonary.ElementAt(0).Key);

                    //Move Pointer
                    if (Pointer != null)
                    {
                        Pointer.Position = Raycaster.Camera.Position + (Raycaster.RayDirection * dictonary.ElementAt(0).Value);
                    }

                    int     index = Models[0].Meshes[0].GetNearestVertexIndex(Pointer.Position);
                    Texture tex   = Models[0].Material.Texture;

                    Vector2 uvpos = Models[0].Meshes[0].UVs[index] * new Vector2(tex.Width, tex.Height);

                    if (Engine.Core.IsMouseClicked(0))
                    {
                        Area(tex, uvpos, 3, -0.02f);
                    }
                    else if (Engine.Core.IsMouseClicked(1))
                    {
                        Area(tex, uvpos, 3, 0.02f);
                    }

                    //
                }
            }

            //
        }