Пример #1
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EDButton.CreateBtn("监视实体决策执行", 150, 50, () =>
            {
                EntityEditorViewHelp help            = target as EntityEditorViewHelp;
                NodeRunSelEntityHelp.SelEntityId     = help.EntityId;
                NodeRunSelEntityHelp.RefreshRunState = false;
            });

            EDButton.CreateBtn("刷新决策执行", 150, 50, () =>
            {
                NodeRunSelEntityHelp.RunningNodes.Clear();
            });
        }
Пример #2
0
        private static void DrawEntity(EntityEditorViewHelp targetCom)
        {
            Entity entity = ECSLocate.ECS.GetEntity(targetCom.EntityId);

            if (entity == null)
            {
                return;
            }

            List <EntityComView> comViews = HandleEntityComs(entity);
            Rect showRect = targetCom.ShowRect;

            //渲染
            Handles.BeginGUI();
            GUILayout.BeginArea(showRect);

            //基础按钮和信息
            EDTypeField.CreateLableField("实体名:", targetCom.name, showRect.width, 20);
            EDTypeField.CreateLableField("实体状态:", entity.IsEnable.ToString(), showRect.width, 20);
            EDButton.CreateBtn("激活/禁用 实体", 100, 50, () => {
                if (entity.IsEnable)
                {
                    entity.Disable();
                }
                else
                {
                    entity.Enable();
                }
            });
            EDButton.CreateBtn("显示组件", 100, 50, () => {
                ShowComs = ShowComs?false:true;
            });
            EDButton.CreateBtn("显示系统", 100, 50, () => {
                ShowSystems = ShowSystems?false:true;
            });

            //组件列表
            DrawEntityComs(ShowComs, comViews, showRect.width, showRect.height * 0.7f);

            //系统列表
            DrawEntitySystem(ShowSystems, entity.Systems, showRect.width, showRect.height * 0.7f);

            GUILayout.EndArea();
            Handles.EndGUI();
        }
Пример #3
0
        private static void OnSceneGUI(SceneView sceneView)
        {
            GameObject go = Selection.activeGameObject;

            if (go != null)
            {
                EntityEditorViewHelp entityView = go.GetComponent <EntityEditorViewHelp>();
                if (entityView != null)
                {
                    SelEntityView = entityView;
                }
            }

            if (SelEntityView != null && SelEntityView.DrawEditor)
            {
                DrawEntity(SelEntityView);
            }
        }
Пример #4
0
        public Entity CreateProduct(Action <object[]> func, params object[] data)
        {
            //解析参数
            int        entityId   = int.Parse(data[0].ToString());
            string     entityName = data[1].ToString();
            GameObject entityGo   = data.Length > 2?data[2] as GameObject:null;

            //配置数据
            EntityJson entityData = ECSLayerLocate.Info.GetEntityConf(entityName);

            if (entityData == null)
            {
                ECSLocate.ECSLog.LogError("实体配置数据不存在>>>>>>>", entityName);
                return(null);
            }

            //创建实体节点
            if (entityGo == null)
            {
                entityGo = (GameObject)ECSLocate.Factory.GetProduct <Object>(FactoryType.Asset, null, entityData.PrefabPath);
                entityGo = Object.Instantiate(entityGo);
            }
            if (entityGo == null)
            {
                ECSLocate.ECSLog.LogR("有一个实体没有节点>>>>>>>>", entityId, entityName);
            }
            else
            {
#if UNITY_EDITOR
                EntityEditorViewHelp sceneHelp = entityGo.AddComponent <EntityEditorViewHelp>();
                sceneHelp.EntityId = entityId;
#endif
            }

            //创建实体
            Entity entity = new Entity();

            //添加组件
            for (int i = 0; i < entityData.Coms.Count; i++)
            {
                EntityComJson comJson = entityData.Coms[i];
                BaseCom       com     = LCReflect.CreateInstanceByType <BaseCom>(comJson.ComName);

                //赋值
                for (int j = 0; j < comJson.Values.Count; j++)
                {
                    EntityComValueJson valueJson = comJson.Values[j];

                    object value = LCConvert.StrChangeToObject(valueJson.Value, valueJson.Type);
                    LCReflect.SetTypeFieldValue(com, valueJson.Name, value);
                }

                com.Init(entityId, entityGo);
                entity.AddCom(com);
            }

            func?.Invoke(new object[] { entityGo });

            ECSLocate.ECSLog.LogR("创建实体成功>>>>>>>>", entityName);
            return(entity);
        }