Beispiel #1
0
        void Randomize()
        {
            if (r == null || item == null)
            {
                return;
            }

            int amount = Random.Range(r.amount.x, r.amount.y);

            for (int i = 0; i < amount; i++)
            {
                Vector3 pos    = new Vector3(Random.Range(r.posX.x, r.posX.y), 0, Random.Range(r.posZ.x, r.posZ.y));
                float   rotY   = Random.Range(r.rotY.x, r.rotY.y);
                float   scaleX = Random.Range(r.scaleX.x, r.scaleX.y);
                Vector3 scale  = new Vector3(scaleX, Random.Range(r.scaleY.x, r.scaleY.y), scaleX);

                TC_ItemBehaviour newItem = item.Duplicate(item.t.parent);
                newItem.t.position   = pos;
                newItem.t.rotation   = Quaternion.Euler(0, rotY, 0);
                newItem.t.localScale = scale;
                newItem.method       = Method.Max;
            }

            TC.AutoGenerate();
        }
Beispiel #2
0
        static public void DuplicateKey()
        {
            Transform[] transforms = (Transform[])Selection.transforms.Clone();

            if (transforms != null)
            {
                List <GameObject> gos = new List <GameObject>();

                for (int i = 0; i < transforms.Length; i++)
                {
                    Transform t = transforms[i];

                    TC_LayerGroup       layerGroup      = t.GetComponent <TC_LayerGroup>();
                    TC_LayerGroupResult groupResult     = t.GetComponent <TC_LayerGroupResult>();
                    TC_SelectItemGroup  selectItemGroup = t.GetComponent <TC_SelectItemGroup>();
                    TC_NodeGroup        nodeGroup       = t.GetComponent <TC_NodeGroup>();

                    if (layerGroup != null)
                    {
                        if (layerGroup.level == 0)
                        {
                            TC.AddMessage("The main " + TC.outputNames[layerGroup.outputId] + " Output Layer Group cannot be duplicated."); continue;
                        }
                    }
                    else if (groupResult != null)
                    {
                        TC.AddMessage("A Result Node cannot be duplicated."); continue;
                    }
                    else if (selectItemGroup != null)
                    {
                        TC.AddMessage("A " + TC.outputNames[selectItemGroup.outputId] + " Group cannot be directly duplicated.\n\nDrag & drop works with it, while dropping hold the alt key to duplicate it."); continue;
                    }
                    else if (nodeGroup != null)
                    {
                        TC.AddMessage("A " + nodeGroup.type.ToString() + " Group cannot be directly duplicated.\n\nDrag & drop works with it, while dropping hold the alt key to duplicate it."); continue;
                    }

                    TC_ItemBehaviour item = t.GetComponent <TC_ItemBehaviour>();
                    if (item != null)
                    {
                        gos.Add(item.Duplicate(item.transform.parent).gameObject);
                    }
                }
                if (gos.Count > 0)
                {
                    Selection.objects = gos.ToArray();
                }
            }
        }