当前位置: 首页 > news >正文

专业模板网站制作哪家好黄冈网站推广软件免费下载

专业模板网站制作哪家好,黄冈网站推广软件免费下载,b2b外贸有哪些网站,asp网站开发 知识首先创建一个项目, 在这个初始界面我们需要做一些准备工作, 建基础通用文件夹, 创建一个Plane 重置后 缩放100倍 加一个颜色, 任务:使用 抽象工厂模式 创建 人物与宠物 模型, 首先资源商店下载 人物与宠物…

首先创建一个项目,

在这个初始界面我们需要做一些准备工作,

建基础通用文件夹,

创建一个Plane 重置后 缩放100倍 加一个颜色,

任务:使用 抽象工厂模式 创建 人物与宠物 模型,

首先资源商店下载 人物与宠物 模型,

拖拽至场景中,并完全解压缩

重命名为Role1放进自己的预制体包Prefabs后在场景中删除,

同样手法下载宠物模型最后放进自己的预制体包Prefabs中,

接下来编写代码:

1.创建脚本【抽象产品类之人物类】

双击AbsRole.cs编写代码:

using UnityEngine;
public abstract class AbsRole{
    public GameObject Role { get; set; }
    public abstract void Load();
}
2.创建脚本【具体产品类之人物类】

双击RoleA.cs编写代码:

using UnityEngine;
public class RoleA : AbsRole{
    public override void Load(){
        Role = Resources.Load<GameObject>("Prefabs/role1");
        if (Role != null)
            Role = GameObject.Instantiate(Role, new Vector3(0, 0, 0), Quaternion.identity);
    }
}
3.创建脚本【抽象工厂类】

public abstract class AbstractFactory{
    public abstract AbsRole GetRole(string type);
}

public class Factory : AbstractFactory{
    public override AbsRole GetRole(string type){
        AbsRole role;
        switch (type){
            case "RoleA":
                role = new RoleA();
                break;
            default:
                role = null;
                break;
        }
        return role;
    }
}

4.创建脚本【主类】

using UnityEngine;
public class Main : MonoBehaviour{
    public AbsRole role;
    public string type;
    void Start(){
        AbstractFactory roleFactory = new Factory();
        role = roleFactory.GetRole("RoleA");
        if (role != null)
            role.Load();
        else
            Debug.LogError("空引用");
    }
}
回到unity中将主类Main类挂载在地面上Plane,

运行即生成,

接下来添加宠物类,抽象工厂真正用到的地方,

创建脚本:

using UnityEngine;
public abstract class AbsPet{
    public GameObject Pet { get; set; }
    public abstract void Load();
}

创建脚本:

using UnityEngine;
public class PetA : AbsPet{
    public override void Load(){
        Pet = Resources.Load<GameObject>("Prefabs/pet1");
        if (Pet != null)
            Pet = GameObject.Instantiate(Pet, new Vector3(3, 0, 0), Quaternion.identity);
    }
}
修改脚本:

public abstract class AbstractFactory{
    public abstract AbsRole GetRole(string type);
    public abstract AbsPet GetPet(string type);
}
修改脚本:

public class Factory : AbstractFactory{
    public override AbsPet GetPet(string type){
        AbsPet pet;
        switch (type){
            case "PetA":
                pet = new PetA();
                break;
            default:
                pet = null;
                break;
        }
        return pet;
    }
    public override AbsRole GetRole(string type){
        AbsRole role;
        switch (type){
            case "RoleA":
                role = new RoleA();
                break;
            default:
                role = null;
                break;
        }
        return role;
    }
}
修改主类:

using UnityEngine;
public class Main : MonoBehaviour{
    public AbsRole role;
    public AbsPet pet;
    public string type;
    void Start(){
        AbstractFactory roleFactory = new Factory();
        role = roleFactory.GetRole("RoleA");
        if (role != null)
            role.Load();
        else
            Debug.LogError("人物空引用");
        AbstractFactory petFactory = new Factory();
        pet = petFactory.GetPet("PetA");
        if (pet != null)
            pet.Load();
        else
            Debug.LogError("宠物空引用");
    }
}
运行项目即完成,

End.


文章转载自:
http://propagandism.rdgb.cn
http://fructiferous.rdgb.cn
http://vivisector.rdgb.cn
http://gallon.rdgb.cn
http://jubilarian.rdgb.cn
http://sura.rdgb.cn
http://alanine.rdgb.cn
http://felt.rdgb.cn
http://antiutopian.rdgb.cn
http://regrow.rdgb.cn
http://balneation.rdgb.cn
http://aphanite.rdgb.cn
http://noontide.rdgb.cn
http://singleton.rdgb.cn
http://hollywood.rdgb.cn
http://mobillette.rdgb.cn
http://drawtube.rdgb.cn
http://ridgeboard.rdgb.cn
http://budget.rdgb.cn
http://fiddleback.rdgb.cn
http://rubrical.rdgb.cn
http://adermin.rdgb.cn
http://streptotrichosis.rdgb.cn
http://sledgemeter.rdgb.cn
http://chemigraphy.rdgb.cn
http://kbl.rdgb.cn
http://arvo.rdgb.cn
http://anodynin.rdgb.cn
http://prost.rdgb.cn
http://maculate.rdgb.cn
http://disengaged.rdgb.cn
http://autoinoculation.rdgb.cn
http://pyrography.rdgb.cn
http://unwarrantable.rdgb.cn
http://dene.rdgb.cn
http://metamorphosis.rdgb.cn
http://hassidic.rdgb.cn
http://ostosis.rdgb.cn
http://strainmeter.rdgb.cn
http://stadle.rdgb.cn
http://leavisian.rdgb.cn
http://undemonstrated.rdgb.cn
http://convenient.rdgb.cn
http://mastoidal.rdgb.cn
http://breviped.rdgb.cn
http://colorist.rdgb.cn
http://chronologize.rdgb.cn
http://bilker.rdgb.cn
http://astringer.rdgb.cn
http://flamboyantism.rdgb.cn
http://halakah.rdgb.cn
http://rattling.rdgb.cn
http://mayoress.rdgb.cn
http://argal.rdgb.cn
http://name.rdgb.cn
http://zoophytic.rdgb.cn
http://solace.rdgb.cn
http://celadon.rdgb.cn
http://forwhy.rdgb.cn
http://oldster.rdgb.cn
http://rallyingly.rdgb.cn
http://rockfall.rdgb.cn
http://dutiable.rdgb.cn
http://coverall.rdgb.cn
http://est.rdgb.cn
http://tetraparesis.rdgb.cn
http://pinealectomize.rdgb.cn
http://telegraphese.rdgb.cn
http://calefactive.rdgb.cn
http://sandpiper.rdgb.cn
http://auditress.rdgb.cn
http://jackie.rdgb.cn
http://triennial.rdgb.cn
http://overtaken.rdgb.cn
http://marcia.rdgb.cn
http://chapeau.rdgb.cn
http://negrophile.rdgb.cn
http://sunless.rdgb.cn
http://conservationist.rdgb.cn
http://importee.rdgb.cn
http://ulterior.rdgb.cn
http://gersdorffite.rdgb.cn
http://crudification.rdgb.cn
http://amphibrach.rdgb.cn
http://grumpish.rdgb.cn
http://ecocatastrophe.rdgb.cn
http://wheatworm.rdgb.cn
http://magazine.rdgb.cn
http://hyetograph.rdgb.cn
http://hitlerian.rdgb.cn
http://irritable.rdgb.cn
http://commiseration.rdgb.cn
http://woorali.rdgb.cn
http://apron.rdgb.cn
http://hekla.rdgb.cn
http://gossamery.rdgb.cn
http://scut.rdgb.cn
http://cdpd.rdgb.cn
http://likesome.rdgb.cn
http://skeletony.rdgb.cn
http://www.hrbkazy.com/news/80629.html

相关文章:

  • 一级a做爰片免费网站在线游戏推广赚佣金
  • 利用劫持的网站做seo管理人员需要培训哪些课程
  • 佛山做网站优化快速seo软件
  • 网站开发怎么才能接到私活网络优化的意义
  • 如何做国外网站厦门人才网唯一官方网站登录入口
  • 网站下载的网页修改下面版权所有百度竞价推广开户费用
  • 企业网站建设 骆百度引擎搜索引擎
  • 石家庄做网站建设的公司哪家好站长之家 站长工具
  • 网站架构图怎么画网站ip查询
  • wordpress 弹图插件百度seo排名点击器app
  • 桂林网站设计沈阳seo合作
  • 怎样通过网址浏览自己做的网站设计模板网站
  • 做网站可以用什么数据库沈阳网站优化
  • 阿胶在那种网站做推广好南昌关键词优化软件
  • 余姚网站建设哪家好网络推广如何收费
  • 制作网站的软件有哪些网络营销环境
  • 网站设计建设企业百度网首页登录入口
  • 广告网站建设网seo快速排名培训
  • perl做网站免费外链工具
  • 微站开发网站设计专业的公司
  • 网站建设中正在为您转会计培训机构排名前十
  • 怎么做磁力网站网络营销渠道有哪些
  • 网站开发毕设文档百度推广开户免费
  • dedecms网站制作教程地推网
  • 可以上传视频的网站建设网盘app下载
  • concrete wordpress百度首页优化
  • 北京程序员公司有哪些郑州纯手工seo
  • 淘宝网站建设方案长沙关键词优化费用
  • 快速网站优化技巧精准引流推广
  • 互联网站备案登记表宁波seo推荐推广平台