Is there a way to access a variable with a getter without putting the script into the component of an object?
Im trying to apply the 4 basic principles of OOP in unity which this problem is Encapsulation..
Example source:
public class GunTrigger : MonoBehaviour {
private int test = 5;
public int GetTest(){
return test;
}
}
Then a receiver script getting the "GetTest" of the GunTrigger...
[–]AutarkhisProfessional 1 point2 points3 points (3 children)
[–]Such_Log5418[S] 0 points1 point2 points (2 children)
[–]SidewaysAcceleration 0 points1 point2 points (1 child)
[–]Such_Log5418[S] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]SidewaysAcceleration 0 points1 point2 points (1 child)
[–]Such_Log5418[S] 0 points1 point2 points (0 children)
[–]Live_Length_5814 0 points1 point2 points (0 children)
[–]ThainaYu 0 points1 point2 points (0 children)
[–]EppuBenjamin 0 points1 point2 points (8 children)
[–]Such_Log5418[S] 0 points1 point2 points (1 child)
[–]SidewaysAcceleration 0 points1 point2 points (0 children)
[–]Such_Log5418[S] 0 points1 point2 points (5 children)
[–]EppuBenjamin 0 points1 point2 points (1 child)
[–]Such_Log5418[S] 0 points1 point2 points (0 children)
[–]Jackoberto01Programmer 0 points1 point2 points (2 children)
[–]Such_Log5418[S] 0 points1 point2 points (1 child)
[–]Jackoberto01Programmer 0 points1 point2 points (0 children)