Esempio n. 1
0
        public static void SelectObjectEntitiesManyToMany(ManyToManyRelationship rel)
        {
            List <GameObject> go = new List <GameObject>();

            go.AddRange(rel.objectEntities.Select(ent => ent.gameObject));
            Selection.objects = go.ToArray();
        }
Esempio n. 2
0
        protected ManyToManyRelationship AddManyToManyRelationship(string ownerEntityId, List <string> subjectEntitiesId, List <string> objectEntitiesId)
        {
            GameObject             ownerObject = entityObjects[ownerEntityId];
            ManyToManyRelationship manyToMany  = ownerObject.AddComponent <ManyToManyRelationship>();

            manyToMany.subjectEntities = new List <EntityData>(subjectEntitiesId.Count);
            foreach (string id in subjectEntitiesId)
            {
                manyToMany.subjectEntities.Add(entityObjects[id].GetComponent <EntityData>());
            }
            manyToMany.objectEntities = new List <EntityData>(objectEntitiesId.Count);
            foreach (string id in objectEntitiesId)
            {
                manyToMany.objectEntities.Add(entityObjects[id].GetComponent <EntityData>());
            }
            foreach (string id in objectEntitiesId)
            {
                manyToMany.objectEntities.Add(entityObjects[id].GetComponent <EntityData>());
            }
            // update cross references
            manyToMany.OnValidate();
            return(manyToMany);
        }
Esempio n. 3
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);
                }
            }
        }