zoukankan      html  css  js  c++  java
  • 2018.8.14笔记


    setsiblingindex(idx)设置兄弟结点先后顺序时,若idx处已有结点X,则结点X及其后的所有节点后移

    gc alloc,就是申请堆内存,堆内存申请无处不在,不可能保持为0,
    U3D文档中说,尽可能保持这个值为0,是说在UPDATE中,因为UPDATE是个频繁调用的函数,
    就算每帧有一点内存申请,时间累积下来也就会有很多,就会引发GC。

    Note that some script methods cause allocations when running in the Editor, but do not produce allocations after the project has been built. GetComponent is the most common example; this method always allocates when executed in the Editor, but not in a built project.
    【Understanding the managed heap】

    一,对扩展开放,对修改封闭
    1,模板方法: 有一个固定的算法框架,但算法的各步骤允许重写,利用虚函数让子类重写
    2,策略模式 有多种方法可以灵活切换时,
    例: 各国税收计算
    stra->stra1,stra2,stra3
    var ps = setstretage(new stra1())
    ps->calc()
    var ps1 = setstretage(new stra2())
    ps1->calc()
    二,解决功能类组合爆炸
    3,装饰者模式,
    stream->filestream,networkstream,memorystream
    bufferedStream, cryptoStream, ....
    var b1 = new bufferedStream(new filestream())
    var b2 = new bufferedStream(new networkstream())
    var b3 = new bufferedStream(new memorystream())
    new cryptoStream(b1)
    new cryptoStream(b2)
    new cryptoStream(b3)
    new cryptoStream(new filestream())
    new cryptoStream(new networkstream())
    new cryptoStream(new memorystream())

    4,桥接模式 bridge,与装饰者模式有很像,感觉像是装饰模式和策略模式的合体
    abstract-> impAbs
    funclassA,funclassB, funclassC
    其中:impAbs中有 RefinedOperation,在其中调用 funclassA或funclassB或 funclassC中的Operation

    var abstract* pabs = new impAbs()
    pabs->SetImpl(new funclassA())
    pabs->RefinedOperation() //调用A的operation,并在其基础上进行优化
    pabs->SetImpl(new funclassB())
    pabs->RefinedOperation()//调用B的operation,并在其基础上进行优化

    5,工厂模式
    5.1简单工厂模式
    把对象的生成放到一个工厂函数中,使用者只需传入类型就能得到产品
    car = factory.CreateCar("bwm")
    其中 CreateCar只是简单的通过if else来new不同对象并返回
    5.2工厂方法模式
    因为简单工厂在增加新类型产品时需要修改 CreateCar,违反了对修改封闭,对扩展开放原则,
    因此考虑将变化封装出来,于是便有了工厂方法模式
    bmwFactory, benchiFactory, xcarFactory
    bmw = bmwFactory.createCar()
    benchi = benchiFactory.createCar()
    5.3抽象工厂方法模式,在5.2基础上进行更多的工厂类,并有抽象基类
    6,命令模式: 命令发送者-命令-接收者,发送者和接收者通过命令解耦
    发送者执行命令,命令调用接收者,接收者执行动作
    -------------------------------------------------------------------------------
    public interface ICommand{
    void Execute();
    }
    public class ConcreteCommandA : ICommand{
    public ConcreteCommandA(Receiver receiver){this.receiver = receiver;}
    public void Execute(){this.receiver.DoA();}
    }
    public class ConcreteCommandB : ICommand{
    private Receiver receiver = null;
    public ConcreteCommandB(Receiver receiver)
    public void Execute(){this.receiver.DoB();}
    }
    public class Receiver
    public void DoA(){}
    public void DoB(){}
    }
    public class Invoker{
    public void SetCommand(ICommand command)
    public void RunCommand(){ command.Execute(); }
    }
    public class Client
    {
    public Client()
    {
    Receiver receiver = new Receiver();
    Invoker invoker = new Invoker();
    invoker.SetCommand(new ConcreteCommandA(receiver));
    invoker.RunCommand();
    invoker.SetCommand(new ConcreteCommandB(receiver));
    invoker.RunCommand();
    }
    }
    -------------------------------------------------------------------------------
    7,中介模式,很简单的一个模式,它和代理模式的区别?
    中介注重于A,B两个类不直接交互,而是通过中介交换信息,就像中介所介绍对象
    代理模式侧重于代理A去做事,可能是向B交互,也可能是更广义的做任务事
    代理主要是为了给A包装一层,可用于安全处理等

    8,代理模式,将A放入代理类B中,通过B操作A

    ————————————————————————————————————————————————————————————

    1,顶点压缩,reduces the file size of the Mesh, but might introduce irregularities.
    2,查看build log,可以看到各种类型的资源所占有空间大小,及空间占用从大到小排列的具体各资源的列表
    3,U3D在导入纹理时是边导边压缩的,因此导入图片会很慢,在开发时可以关掉这个选项:prefercen, compress asset on import

    减小打包尺寸
    一,纹理
    1,选择合适的纹理压缩方式
    2,更改纹理尺寸:并不需要改实际图片,只需要在设置中更改max size就行了
    3,2的N次方规则+4N规则
    二,MESH
    1,模型属性面板的MODEL分页卡中选择Mesh Compression low/medium/high
    这可以减小打包的MESH大小,但可能会导致不精确(动作,蒙皮等),手册上说这并不会减小运行内存
    其实应该也是会的,因为模型顶点少了啊,若说在运行时顶点数目又通过某种算法还原了,倒有可能。
    2,减小关键帧数量
    Animation keyframe reduction produces smaller data files and uses less memory at run time; generally you should always have it enabled.
    这个是可以很明显的减小运行内存,又可以减小打包尺寸
    三,DLL
    U3D必须的几个DLL: mscorlib.dll boo.lang.dll unityscript.lang.dll unityengine.dll
    默认情况下不带system.dll,system.xml.dll,这两个DLL大约1M多,当使用了相关类时,这两个DLL会被自动导入

    四,Reducing mobile .NET library size

    avatar存在的目的: 1,动作遮罩,2,动作重定向
    ------------------------------------
    Animation Layer syncing????
    ------------------------------------
    重定向???

  • 相关阅读:
    Java中DAO的实现
    使用Fabric自动化你的任务
    JAVA中处理事务的程序--多条更新SQL语句的执行(包括回滚)
    财政业务流程
    ubuntu 14.04 install google chrom stable
    gcc编译命令
    textread 用法
    ubuntu software
    Coursera.org打不开怎么办
    Presentation__short sentence review mining
  • 原文地址:https://www.cnblogs.com/timeObjserver/p/9472319.html
Copyright © 2011-2022 走看看