Visar inlägg med etikett Unity. Visa alla inlägg
Visar inlägg med etikett Unity. Visa alla inlägg

måndag 11 juli 2022

OpenArtViewer

I've made an art viewer program in Unity. I'm now working on database update automatization in Python. That is because the files with art information provided are updated frequently.

OpenArtViewer uses the National Gallery of Art Open Data API and data from Metropolitan Museum of Art. The included SQLite database has stored info about the artworks in public domain (100K+) including image links to the artworks on the NGA and MM servers. 

From the GUI you can search type of art and by title, year, artist. To the left there's a scroll bar with the results as thumbnails. These can be clicked to get more information and a higher resolution version of the artwork in the big panel to the right. A high resolution image can then be downloaded. 

Download this program (Windows) https://wartem.se/files/OpenArtViewer.zip




National Gallery of Art

Metropolitan Museum of Art

måndag 15 november 2021

Unity - How to get access and change the camera distance while using Cinemachine "3rd person follow" (C#)

Cinemachine https://unity.com/unity/features/editor/art-and-design/cinemachine

saves time by letting you create difference kinds of cameras.


Let's say you want to use the input system and scroll the mouse to change the camera distance.

I couldn't find a clear solution online so I thought I share:


First make sure you have:

A player GameObject.

A GameObject with a CinemachineVirtualCamera, set to: 

* follow the player.

* its "Body" set to "3rd Person Follow".


Note: You have other body properties as well to chose from:

3rd Person follow

Framing Transposer

Hard Lock to Target

Orbital Transposer

Tracked Dolly

Transposer


We are focusing on the "3rd Person Follow" now.


In the script that you add as component to the player GameObject:


Declaration: 

private GameObject _playerFollowCamera;

public CinemachineVirtualCamera _cinemachineVirtualCamera;


In private void Start() :

_playerFollowCamera = GameObject.Find("PlayerFollowCamera");

_cinemachineVirtualCamera = _playerFollowCamera.GetComponent<CinemachineVirtualCamera>();


          In your method, called when scrolling for example: 

CinemachineComponentBase cinemachineComponentBase = _cinemachineVirtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Body);


if (cinemachineComponentBase is Cinemachine3rdPersonFollow)

{

(cinemachineComponentBase as Cinemachine3rdPersonFollow).CameraDistance = yourCameraDistanceValue;

}


Or as one line:

(GameObject.Find("PlayerFollowCamera").GetComponent<CinemachineVirtualCamera>().GetCinemachineComponent(CinemachineCore.Stage.Body) 

as Cinemachine3rdPersonFollow).CameraDistance = yourCameraDistanceValue;


"Cinemachine3rdPersonFollow" above is changed depending on which body property you are using.