Ejemplo n.º 1
0
    void Update()
    {
        if (this.requested != null)
        {
            var srcObj = GameObject.Find($"/{this.requested.Src}");
            var dstObj = GameObject.Find($"/{this.requested.Dst}");

            if (srcObj == null)
            {
                Debug.LogError($"[MsgInstantiator] Could not find src object with id `{this.requested.Src}`");
                return;
            }

            if (dstObj == null)
            {
                Debug.LogError($"[MsgInstantiator] Could not find dst object with id `{this.requested.Dst}`");
                return;
            }

            Vector3 start = srcObj.transform.position;
            Vector3 end   = dstObj.transform.position;

            Msg copy = Instantiate <Msg>(this.Object, start, Quaternion.identity);
            copy.StartPoint = start;
            copy.EndPoint   = end;
            copy.Duration   = 2f; // In seconds

            // Reset
            this.requested = null;
        }
    }
Ejemplo n.º 2
0
 public void CreateNew(string name = null)
 {
     this.requested = new InstantiationRequest()
     {
         Name = name
     };
 }
 public void CreateNew(string srcId, string dstId)
 {
     this.requested = new InstantiationRequest()
     {
         Src = srcId,
         Dst = dstId
     };
 }
Ejemplo n.º 4
0
 public void AddInstantiationRequest(InstantiationRequest i)
 {
     if (i == null)
     {
         throw new Exception("Instatiation Request cannot be null");
     }
     instatiationRequests.Add(i);
 }
Ejemplo n.º 5
0
    void Update()
    {
        if (this.requested != null)
        {
            Transform copy = Instantiate(this.Object, this.NewDisplacementVector, Quaternion.identity);

            // Assign new name
            // 1. Requested name
            // 2. Otherwise, template object prefixed name
            // 3. Otherwise default prefixed name
            copy.name = this.requested.Name ?? this.NewName(this.Object.name ?? "obj");

            // Add to cache
            this.instances.Add(copy);

            // Reset
            this.requested = null;
        }
    }
    void Update()
    {
        if (this.requested != null)
        {
            var srcObj = GameObject.Find($"/{this.requested.Src}");
            var dstObj = GameObject.Find($"/{this.requested.Dst}");

            if (srcObj == null)
            {
                Debug.LogError($"[ConnectorInstantiator] Could not find src object with id `{this.requested.Src}`");
                return;
            }

            if (dstObj == null)
            {
                Debug.LogError($"[ConnectorInstantiator] Could not find dst object with id `{this.requested.Dst}`");
                return;
            }

            Vector3 start = srcObj.transform.position;
            Vector3 end   = dstObj.transform.position;

            float   width    = 0.2f;
            Vector3 offset   = end - start;
            Vector3 scale    = new Vector3(width, offset.magnitude / 2f, width);
            Vector3 position = start + (offset / 2f);

            Transform copy = Instantiate(this.Object, position, Quaternion.identity);

            // Assign a name which will reflect the connector's nature
            copy.name = $"{this.requested.Src}__{this.requested.Dst}";

            copy.transform.up         = offset;
            copy.transform.localScale = scale;

            // Add to cache
            this.instances.Add(copy);

            // Reset
            this.requested = null;
        }
    }