public static void SetupOneToManyRelationship(OneToManyRelationship rel, string name)
        {
            SetupRelationship(rel, name);
            GameObject selObj = rel.gameObject;

            rel.subjectEntity = selObj.GetComponent <EntityData>();
        }
        public static void SelectObjectEntitiesOneToMany(OneToManyRelationship rel)
        {
            List <GameObject> go = new List <GameObject>();

            go.AddRange(rel.objectEntities.Select(ent => ent.gameObject));
            Selection.objects = go.ToArray();
        }
示例#3
0
        protected OneToManyRelationship AddOneToManyRelationship(string ownerEntityId, string subjectEntityId, List <string> objectEntitiesId)
        {
            GameObject            ownerObject = entityObjects[ownerEntityId];
            OneToManyRelationship oneToMany   = ownerObject.AddComponent <OneToManyRelationship>();

            SetupOneToManyRelationship(oneToMany, ownerEntityId, subjectEntityId, objectEntitiesId);
            return(oneToMany);
        }
示例#4
0
 protected void SetupOneToManyRelationship(OneToManyRelationship oneToMany, string ownerEntityId, string subjectEntityId, List <string> objectEntitiesId)
 {
     oneToMany.subjectEntity  = entityObjects[subjectEntityId].GetComponent <EntityData>();
     oneToMany.objectEntities = new List <EntityData>(objectEntitiesId.Count);
     foreach (string id in objectEntitiesId)
     {
         oneToMany.objectEntities.Add(entityObjects[id].GetComponent <EntityData>());
     }
     // update cross references
     oneToMany.OnValidate();
 }
        public static void IncludeChildrenInRelationship(OneToManyRelationship rel)
        {
            GameObject selObj = rel.gameObject;

            if (rel.objectEntities == null)
            {
                rel.objectEntities = new List <EntityData>();
            }
            for (int i = 0; i < selObj.transform.childCount; i++)
            {
                var childEntity = selObj.transform.GetChild(i).gameObject.GetComponent <EntityData>();
                if (childEntity)
                {
                    rel.objectEntities.Add(childEntity);
                }
            }
            rel.OnValidate();
        }
示例#6
0
        private void ParseRelationship()
        {
            connectionList.Clear();
            if (linesObject)
            {
                Destroy(linesObject);
            }
            linesObject = new GameObject(relationshipComponent.id + "_Lines");
            linesObject.transform.parent = transform;
            relationshipOneToOne         = relationshipComponent as OneToOneRelationship;
            relationshipOneToMany        = relationshipComponent as OneToManyRelationship;
            relationshipManyToMany       = relationshipComponent as ManyToManyRelationship;

            if (relationshipOneToOne)
            {
                RelationshipConnection conn = new RelationshipConnection();
                var lr = linesObject.AddComponent <LineRenderer>();
                lr.startWidth = 0.1f;
                lr.endWidth   = 0.1f;
                lr.startColor = Color.magenta;
                lr.endColor   = Color.magenta;
                lr.material   = Resources.Load("Materials/Line") as Material;
                //lr.material.color = Color.magenta;
                conn.lineRenderer   = lr;
                conn.startTransform = relationshipOneToOne.subjectEntity.transform;
                conn.endTransform   = relationshipOneToOne.objectEntity.transform;
                connectionList.Add(conn);
            }

            if (relationshipOneToMany)
            {
                foreach (var entity in relationshipOneToMany.objectEntities)
                {
                    GameObject line = new GameObject("LineTo" + entity.name);
                    line.transform.parent = linesObject.transform;
                    RelationshipConnection conn = new RelationshipConnection();
                    LineRenderer           lr   = line.AddComponent <LineRenderer>();
                    lr.material = Resources.Load("Materials/Line") as Material;
                    //lr.material.color = Color.magenta;
                    lr.startWidth = 0.1f;
                    lr.endWidth   = 0.1f;
                    lr.startColor = Color.yellow;
                    lr.endColor   = Color.red;

                    conn.lineRenderer   = lr;
                    conn.startTransform = relationshipOneToMany.subjectEntity.transform;
                    conn.endTransform   = entity.transform;
                    connectionList.Add(conn);
                }
            }

            if (relationshipManyToMany)
            {
                foreach (var entity in relationshipManyToMany.subjectEntities)
                {
                    GameObject line = new GameObject("LineFrom" + entity.name);
                    line.transform.parent = linesObject.transform;
                    RelationshipConnection conn = new RelationshipConnection();
                    LineRenderer           lr   = line.AddComponent <LineRenderer>();
                    lr.material   = Resources.Load("Materials/Line") as Material;
                    lr.startWidth = 0.1f;
                    lr.endWidth   = 0.1f;
                    lr.startColor = Color.blue;
                    lr.endColor   = Color.cyan;

                    conn.lineRenderer   = lr;
                    conn.startTransform = entity.transform;
                    conn.endTransform   = relationshipManyToMany.ownerEntity.transform;
                    connectionList.Add(conn);
                }

                foreach (var entity in relationshipManyToMany.objectEntities)
                {
                    GameObject line = new GameObject("LineTo" + entity.name);
                    line.transform.parent = linesObject.transform;
                    RelationshipConnection conn = new RelationshipConnection();
                    LineRenderer           lr   = line.AddComponent <LineRenderer>();
                    lr.material   = Resources.Load("Materials/Line") as Material;
                    lr.startWidth = 0.1f;
                    lr.endWidth   = 0.1f;
                    lr.startColor = Color.yellow;
                    lr.endColor   = Color.red;

                    conn.lineRenderer   = lr;
                    conn.startTransform = relationshipManyToMany.ownerEntity.transform;
                    conn.endTransform   = entity.transform;
                    connectionList.Add(conn);
                }
            }
        }