Example #1
0
        protected void DrawPool(SpawnPool _pool)
        {
            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.Space();

                // Pool Name
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    EditorGUILayout.LabelField("PoolKey :", GUILayout.Width(80));
                    _pool.PoolName = EditorGUILayout.TextField(_pool.PoolName, GUILayout.Width(100));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                // This is the Prefab List
                DrawPrefab(_pool);

                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);

                    // This is the plus button
                    if (GUILayout.Button("+", EditorStyles.toolbarButton, GUILayout.Width(25)))
                    {
                        _pool.Add(new SpawnPrefab());
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Example #2
0
        /// <summary>
        /// Dispose
        /// </summary>
        private void ManagerDispose()
        {
            ReleaseTracedObjects();

            _despawnTaskTimePiece = null;

            _handledQueue = null;

            _handleSpawnPool = null;

            _pools = null;
        }
Example #3
0
        /// <summary>
        /// prespawn func, not use reusepool
        /// </summary>
        /// <param name="_poolName"></param>
        /// <param name="_key"></param>
        /// <returns></returns>
        private Transform Dospawn(string _poolName, string _key, Vector3 _position, Quaternion _quat, Transform _parent, bool _active)
        {
            // nothing in reuse pool, try create a new one
            _handleSpawnPool = GetPool(_poolName);

            // invalid key
            if (_handleSpawnPool == null)
            {
#if DINO_DEBUG
                this.LogEditorOnly(string.Format("invalid key {0}-{1}!", _poolName, _key));
#endif
                return(null);
            }

            if (_handleSpawnPool[_key] == null)
            {
#if DINO_DEBUG
                this.LogEditorOnly(string.Format("no key {0}-{1}!", _poolName, _key));
#endif
                return(null);
            }

            // limit
            if (_handleSpawnPool[_key].Limit != 0 && _handleSpawnPool[_key].SpawnedCount >= _handleSpawnPool[_key].Limit)
            {
#if DINO_DEBUG
                this.LogEditorOnly(string.Format("pool key {0}-{1} reach limit!", _poolName, _key));
#endif
                return(null);
            }

            // log message if needed
            if (!_handleSpawnPool[_key].LogMessage.Equals(""))
            {
#if DINO_DEBUG
                this.LogEditorOnly(_handleSpawnPool[_key].LogMessage);
#endif
            }

            Transform _trans = GameObject.Instantiate(_handleSpawnPool[_key].Resouces, _position, _quat, _root) as Transform;
            _trans.gameObject.SetActive(_active);
            _trans.name = string.Format("{0}|{1}#{2}", _poolName, _key, _handleSpawnPool[_key].SpawnedCount++);
            return(_trans);
        }
Example #4
0
        public Transform Spawn(string _poolName, string _key)
        {
            // nothing in reuse pool, try create a new one
            _handleSpawnPool = GetPool(_poolName);

            // invalid key
            if (_handleSpawnPool == null)
            {
#if DINO_DEBUG
                this.LogEditorOnly(string.Format("invalid key {0}-{1}!", _poolName, _key));
#endif
                return(null);
            }

            if (_handleSpawnPool[_key] == null)
            {
#if DINO_DEBUG
                this.LogEditorOnly(string.Format("no key {0}-{1}!", _poolName, _key));
#endif
                return(null);
            }

            return(Spawn(_poolName, _key, _handleSpawnPool[_key].Resouces.position, _handleSpawnPool[_key].Resouces.rotation, _root, true));
        }
Example #5
0
        protected void DrawPrefab(SpawnPool _pool)
        {
            for (int i = 0; i < _pool.Count; i++)
            {
                // button
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    if (GUILayout.Button("-", _style, GUILayout.Width(25)))
                    {
                        if (i >= 0)
                        {
                            _pool.RemoveAt(i);
                            return;
                        }
                    }

                    EditorGUILayout.LabelField(string.Format("Element: {0}", i + 1), EditorStyles.toolbarButton, GUILayout.MaxWidth(80));

                    if (_pool[i].Resouces)
                    {
                        EditorGUILayout.LabelField(string.Format("Key: {0}", _pool[i].Resouces.name), EditorStyles.toolbarButton, GUILayout.MaxWidth(300));
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Drag Prefab To Get The Key", EditorStyles.toolbarButton, GUILayout.MaxWidth(202));
                    }
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(2);

                // res
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(49);
                    EditorGUILayout.LabelField("Prefab", EditorStyles.toolbarButton, GUILayout.Width(80));
                    _pool[i].Resouces = EditorGUILayout.ObjectField(_pool[i].Resouces, typeof(Transform), false, GUILayout.MaxWidth(221)) as Transform;
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(2);

                // preload
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(49);
                    EditorGUILayout.LabelField("Preload", EditorStyles.toolbarButton, GUILayout.Width(80));
                    _pool[i].Preload = EditorGUILayout.IntField(_pool[i].Preload, GUILayout.MaxWidth(203));
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(2);

                // limit
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(49);
                    EditorGUILayout.LabelField("Limit", EditorStyles.toolbarButton, GUILayout.Width(80));
                    _pool[i].Limit = EditorGUILayout.IntField(_pool[i].Limit, GUILayout.MaxWidth(203));
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(2);

                // message
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Space(49);
                    EditorGUILayout.LabelField("Message", EditorStyles.toolbarButton, GUILayout.Width(80));
                    _pool[i].LogMessage = EditorGUILayout.TextField(_pool[i].LogMessage, GUILayout.MaxWidth(203));
                }
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(15);
            }
        }