Search Unity

Adding multiple Camera values to a single Scriptable Object

Discussion in 'General Discussion' started by ajantaidc, May 8, 2019.

  1. ajantaidc

    ajantaidc

    Joined:
    May 10, 2018
    Posts:
    1
    I have a situation where I need the camera to move around a Canvas when I play "Next" or "previous".
    So whenever I press "Next", for example, the Camera should change its position and Orthographic Size.

    This is a structure to show a "Story" over a single image which has different "Scenes".
    Like this I have multiple Stories.

    I have been experimenting doing something with Scriptable Objects, whereby I have a template of the Story having different Classes.


    The Scriptable Object I'm working with:

    Code (CSharp):
    1.     public class StoryData : MonoBehaviour
    2.     {
    3.         public string StoryName;
    4.         public StorySceneData[] storySceneDatas;
    5.     }
    6.  
    7.     [System.Serializable]
    8.     public class StorySceneData
    9.     {
    10.         public string SceneText;
    11.         public StorySceneCameraData StorySceneCameraData;
    12.     }
    13.  
    14.     [System.Serializable]
    15.     public class StorySceneCameraData
    16.     {
    17.         public Vector3 CameraCoordinates;
    18.         public float CameraSize;
    19.  
    20.         [Button]
    21.         public void SetCamera()
    22.         {
    23.             CameraCoordinates = Camera.main.transform.position;
    24.             CameraSize = Camera.main.orthographicSize;
    25.         }
    26.     }
    I'm using [Naughty Attributes asset][1] to show the button on the inspector. Idea is to set the number of Scenes to an array, adjust the camera and get that value after clicking on the button.

    But the button doesn't appear when placed inside the **StorySceneCameraData**. It's visible inside the main **StoryData**, which I can't use because I need individual Camera data.

    I also tried building a Custom Inspector for this, it didn't work.

    Any Ideas?


    [1]: https://github.com/dbrizov/NaughtyAttributes