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 BeginWritePackage()
     {
         //If not enough time has passed since the last sample, we don't want to write anything
         if( Time.realtimeSinceStartup < m_LastSampleTime + 1f / m_SampleRate )
         {
             m_IsWriting = false;
             return;
         }

         if( m_SampleCount == 1 )
         {
             m_ObjectsPerSample = m_Objects.Count;
             //Debug.Log( "Setting m_ObjectsPerSample to " + m_ObjectsPerSample );
         }
         else if( m_SampleCount > 1 )
         {
             if( m_Objects.Count / m_SampleCount != m_ObjectsPerSample )
             {
                 Debug.LogWarning( "The number of objects sent via a PhotonStreamQueue has to be the same each frame" );
                 Debug.LogWarning( "Objects in List: " + m_Objects.Count + " / Sample Count: " + m_SampleCount + " = " + ( m_Objects.Count / m_SampleCount ) + " != " + m_ObjectsPerSample );
             }
         }

         /*if( m_SampleCount > 1 )
         {
             Debug.Log( "Check: " + m_Objects.Count + " / " + m_SampleCount + " = " + ( m_Objects.Count / m_SampleCount ) + " = " + m_ObjectsPerSample );
         }*/

         m_IsWriting = true;
         m_SampleCount++;
         m_LastSampleTime = Time.realtimeSinceStartup;

     }