Advertisement
LeeMace

Sam Project

Apr 23rd, 2023 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Ollie : MonoBehaviour
  6. {
  7.     public int twenty = 20;
  8.     Sam sam;
  9.  
  10.     void Start()
  11.     {
  12.         print($" {sam.ten}");
  13.     }
  14.  
  15.     public void SetSam(Sam sam)
  16.     {
  17.         this.sam = sam;
  18.     }
  19.    
  20.     void Update()
  21.     {
  22.         print($" {sam.ten}");
  23.     }
  24.     public void Log()
  25.     {
  26.         print($"Ollie {twenty}");
  27.     }
  28. }
  29.  
  30.  
  31. using System.Collections;
  32. using System.Collections.Generic;
  33. using UnityEngine;
  34.  
  35. public class Sam : MonoBehaviour
  36. {
  37.     public int ten = 10;
  38.  
  39.     public void Log()
  40.     {
  41.         print($"Sam {ten}");
  42.     }
  43. }
  44.  
  45. using System.Collections;
  46. using System.Collections.Generic;
  47. using UnityEngine;
  48.  
  49. public class Paz : MonoBehaviour
  50. {
  51.     [SerializeField] GameObject samPrefab;
  52.     [SerializeField] GameObject olliePrefab;
  53.     Sam sam;
  54.     Ollie ollie;
  55.  
  56.     private void Start()
  57.     {
  58.         GameObject samObject = Instantiate(samPrefab);
  59.         GameObject ollieObject = Instantiate(olliePrefab);
  60.         sam = samObject.GetComponent<Sam>();
  61.         ollie = ollieObject.GetComponent<Ollie>();
  62.         sam.Log();
  63.         ollie.Log();
  64.         ollie.SetSam(sam);
  65.     }
  66. }
Tags: Sam Project
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement