コード例 #1
0
ファイル: PaintGrassTool.cs プロジェクト: ubisoft/vrtist
        public void OnSelectGrassItem(object sender, IndexedGameObjectArgs args)
        {
            GameObject item      = args.gobject;
            GrassItem  grassItem = item.GetComponent <GrassItem>();

            SelectGrassObject(grassItem.grassObject);
        }
コード例 #2
0
ファイル: PaintGrassTool.cs プロジェクト: ubisoft/vrtist
        private void OnGrassRemoved(GameObject gObject)
        {
            GrassController grassController = gObject.GetComponent <GrassController>();

            if (null == grassController)
            {
                return;
            }
            foreach (var item in grassList.GetItems())
            {
                GrassItem grassItem = item.Content.GetComponent <GrassItem>();
                if (grassItem.grassObject == gObject)
                {
                    grassList.RemoveItem(item);
                    return;
                }
            }
        }
コード例 #3
0
ファイル: PaintGrassTool.cs プロジェクト: ubisoft/vrtist
        private void OnGrassAdded(GameObject gObject)
        {
            GrassController grassController = gObject.GetComponent <GrassController>();

            if (null == grassController)
            {
                return;
            }

            // Grass is added two times. Dont duplicate.
            bool grassFound = false;

            foreach (var it in grassList.GetItems())
            {
                GrassItem gIt = it.Content.GetComponentInChildren <GrassItem>();
                if (gIt != null)
                {
                    if (gIt.grassObject.name == gObject.name)
                    {
                        grassFound = true;
                    }
                }
            }

            if (!grassFound)
            {
                GameObject grassItemObject = Instantiate(grassItemPrefab);
                GrassItem  grassItem       = grassItemObject.GetComponentInChildren <GrassItem>();
                grassItem.SetGrassObject(gObject);
                Transform         t    = grassItem.transform;
                UIDynamicListItem item = grassList.AddItem(t);
                item.UseColliderForUI = true;
            }
            else
            {
                // TODO: Update image of the item, now that the painting is done.
            }
        }