Пример #1
0
    // Use this for initialization
    void Awake()
    {
        this.GuiManager = GetComponent<GUIManager> ();
        if (this.GuiManager == null)
            Debug.LogError ("GUIManager well linked to service?");

        this.PrefabsFactory = GetComponent<PrefabsFactory> ();
        if (this.PrefabsFactory == null)
            Debug.LogError ("PrefabsFactory well linked to service?");
    }
Пример #2
0
    void Awake()
    {
        Application.targetFrameRate = 100;
        Debug.Log("Starting game, framerate: " + Application.targetFrameRate + ", unityVersion: " + Application.unityVersion + ", running plateform:" + Application.platform);

        prefabsFactory = GetComponent <PrefabsFactory>();
        gameManager    = GetComponent <GameManager>();

        gameState = GameState.MainMenu;

        DontDestroyOnLoad(this);
    }
Пример #3
0
    // Use this for initialization
    void Awake()
    {
        this.GuiManager = GetComponent <GUIManager> ();
        if (this.GuiManager == null)
        {
            Debug.LogError("GUIManager well linked to service?");
        }

        this.PrefabsFactory = GetComponent <PrefabsFactory> ();
        if (this.PrefabsFactory == null)
        {
            Debug.LogError("PrefabsFactory well linked to service?");
        }
    }
Пример #4
0
        private T GetNewInstance <T>() where T : SmallPoolItem
        {
            System.Attribute[] attrs = System.Attribute.GetCustomAttributes(typeof(T));

            foreach (System.Attribute attr in attrs)
            {
                if (attr is PrefabsFactory)
                {
                    PrefabsFactory pF = (PrefabsFactory)attr;
                    if (ObjectsLibrary.Instance.PreLoadObjects.ContainsKey(pF.PrimaryKey))
                    {
                        return(Instantiate(ObjectsLibrary.Instance.PreLoadObjects[pF.PrimaryKey]).AddComponent <T>());
                    }
                }
            }
            return(new GameObject(typeof(T).Name).AddComponent <T>());
        }
Пример #5
0
        public static T GetInstance()
        {
            PrefabsFactory att = (PrefabsFactory)Attribute.GetCustomAttribute(typeof(T), typeof(PrefabsFactory));

            if (att == null || string.IsNullOrEmpty(att.PrimaryKey))
            {
                return(new GameObject(typeof(T).Name).AddComponent <T>());
            }
            else
            {
                var        prefabs = Resources.Load <GameObject>(att.PrimaryKey);
                GameObject go      = Instantiate(prefabs);
                T          rt      = go.GetComponent <T>();

                return(rt == null?go.AddComponent <T>() : rt);
            }
        }