I have a base class: Code (CSharp): [System.Serializable] public class Yatzy_Result_Manager : MonoBehaviour private void Start() { InitiateResultCalculation("P1"); } Code (CSharp): [System.Serializable] public class Yatzy_Result_Calc : Yatzy_Result_Manager public void InitiateResultCalculation(string _playerID) { one = 0; two = 0; three = 0; four = 0; five = 0; six = 0; LoadUI_Objects(); DoNewCalculationAndPopulate("P1"); } I do have the "Yatzy_Result_Manager" script loaded only once. The problem is that Yatzy_Result_Manager Start function is executed twice. If I remove "InitiateResultCalculation" it execute once. InitiateResultCalculation does not have a Start or Awake function. I realise that there is something with the relationship with the scripts that cause this but I would like ti understand why Start() is executed twice. What is it I am doing wrong?
LoadUI_Objects initiate the UI objects (buttons) for the scene by adding the initial text = "0" DoNewCalculationAndPopulate reads a file with current result and populate the UI objects with data from that file.
Is it possible one of those methods is instantiating another copy of your object? Try logging GetInstanceId() in your start method and see if they are actually different objects or the same.
Checked your suggestion and all objects ID's is unique. I did test to disable "Yatzy_Result_Calc" and then It worked. I guess that means that the inheritance is the problem. Also, if I remove all code in Start (Yatzy_Result_Manager), only have a print there, it still executes twice. I just do not get this, I have now disable all code in "Yatzy_Result_Calc" as well as the "System.Serializble" and still get the same problem. Code (CSharp): using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //[System.Serializable] public class Yatzy_Result_Calc : Yatzy_Result_Manager { //private int one, two, three, four, five, six; public void InitiateResultCalculation(string _playerID) { /* one = 0; two = 0; three = 0; four = 0; five = 0; six = 0; */ //LoadUI_Objects(); //DoNewCalculationAndPopulate("P1"); } /* void DoNewCalculationAndPopulate(string _playerID) { Here is the first few lines in Yatzy_Result_Manager Code (CSharp): void Start() { print("++++++++++ Start ++++++++++"); _calc = FindObjectOfType(typeof(Yatzy_Result_Calc)) as Yatzy_Result_Calc; ctrlPath = Application.persistentDataPath + "/Yatzy_Control.yat"; playerPath = Application.persistentDataPath + "/"; print(Application.persistentDataPath); I am not calling "Yatzy_Result_Calc" Result: still execute Start twice!
Now I removed "Yatzy_Result_Calc" script and added a new script: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestScript : Yatzy_Result_Manager { } And no reference to this script from "Yatzy_Result_Manager" and I still get Start twice?
I created a completely new project with the following scripts: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Parent : MonoBehaviour { void Start() { print(">>>>>>>>>>>>> S T A R T <<<<<<<<<<<<<"); } } and: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Child : Parent { } Here is the result: What is it I am missing here?
You have both the Child and Parent component on the same object. Unity will call Start() once for each component on your GameObject. That is why Start() is being called twice.