Exemplo n.º 1
0
        private void SelectObjectThumb(CL_Object clobj)
        {
            if (ModelInit != null)
            {
                Destroy(ModelInit.gameObject);
            }
            var     prefab = resourceLoad.GetPrefabsByModelId(clobj.Model);
            Ray     ray    = Camera.main.ScreenPointToRay(Input.mousePosition);
            Vector3 pos    = Tool.GetRayPointFromY(ray.origin, ray.direction, 0);
            var     obj    = Instantiate(prefab, pos, prefab.transform.rotation);

            obj.transform.localScale *= clobj.ModelSize;
            obj.GetComponent <Collider>().isTrigger = true;
            ModelInit = obj.AddComponent <ModelInit>();
            ModelInit.CanInitMaterial    = CanInitMaterial;
            ModelInit.NotCanInitMaterial = NotCanInitMaterial;
        }
        public override void SetOption(object obj)
        {
            ResourceLoad resource = viewOptions.OtherData as ResourceLoad;
            var          clobj    = obj as CL_Object;

            transform.Find("Name").GetComponent <Text>().text = clobj.Name;
            var       prefabs = resource.GetPrefabsByModelId(clobj.Model);
            Texture2D texture = resource.ObjectPrefabsTexture2D[clobj.Model];
            Sprite    sprite  = Sprite.Create(texture, new Rect(0, 0, 128, 128), Vector2.zero);

            GetComponent <Image>().sprite = sprite;
        }
Exemplo n.º 3
0
        public override void SetOption(object obj)
        {
            KeyValuePair <string, object> keyValue = (KeyValuePair <string, object>)obj;

            transform.Find("Name").GetComponent <Text>().text = keyValue.Key;
            var value = transform.Find("Value").GetComponent <Text>();

            if (keyValue.Key == "Operations")
            {
                List <Operation> list    = keyValue.Value as List <Operation>;
                StringBuilder    builder = new StringBuilder();
                list.ForEach(s => builder.Append(s.Name).Append(' '));
                value.text = builder.ToString();
            }
            else if (keyValue.Key == "Model")
            {
                ResourceLoad resourceLoad = viewOptions.OtherData as ResourceLoad;
                value.text = resourceLoad.GetPrefabsByModelId((int)keyValue.Value).name;
            }
            else
            {
                value.text = keyValue.Value.ToString();
            }
        }