Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

         void Awake()
   {
    _scroll_rect = gameObject.GetComponent();

    if (_scroll_rect.horizontalScrollbar || _scroll_rect.verticalScrollbar)
    {
     Debug.LogWarning("Warning, using scrollbars with the Scroll Snap controls is not advised as it causes unpredictable results");
    }

    if (StartingScreen < 0)
    {
     StartingScreen = 0;
    }

    _screensContainer = _scroll_rect.content;
    if (ChildObjects != null && ChildObjects.Length > 0)
    {
     if (_screensContainer.transform.childCount > 0)
     {
      Debug.LogError("ScrollRect Content has children, this is not supported when using managed Child Objects\n Either remove the ScrollRect Content children or clear the ChildObjects array");
      return;
     }

     InitialiseChildObjectsFromArray();
    }
    else
    {
     InitialiseChildObjectsFromScene();
    }

    if (NextButton)
     NextButton.GetComponent