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

            rel.subjectEntity = selObj.GetComponent <EntityData>();
        }
Example #2
0
        protected OneToOneRelationship AddOneToOneRelationship(string ownerEntityId, string subjectEntityId, string objectEntityId)
        {
            GameObject           ownerObject = entityObjects[ownerEntityId];
            OneToOneRelationship oneToOne    = ownerObject.AddComponent <OneToOneRelationship>();

            oneToOne.subjectEntity = entityObjects[subjectEntityId].GetComponent <EntityData>();
            oneToOne.objectEntity  = entityObjects[objectEntityId].GetComponent <EntityData>();
            // update cross references
            oneToOne.OnValidate();
            return(oneToOne);
        }
Example #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);
                }
            }
        }