Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Ollie : MonoBehaviour
- {
- public int twenty = 20;
- Sam sam;
- void Start()
- {
- print($" {sam.ten}");
- }
- public void SetSam(Sam sam)
- {
- this.sam = sam;
- }
- void Update()
- {
- print($" {sam.ten}");
- }
- public void Log()
- {
- print($"Ollie {twenty}");
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Sam : MonoBehaviour
- {
- public int ten = 10;
- public void Log()
- {
- print($"Sam {ten}");
- }
- }
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Paz : MonoBehaviour
- {
- [SerializeField] GameObject samPrefab;
- [SerializeField] GameObject olliePrefab;
- Sam sam;
- Ollie ollie;
- private void Start()
- {
- GameObject samObject = Instantiate(samPrefab);
- GameObject ollieObject = Instantiate(olliePrefab);
- sam = samObject.GetComponent<Sam>();
- ollie = ollieObject.GetComponent<Ollie>();
- sam.Log();
- ollie.Log();
- ollie.SetSam(sam);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement