unity 杂记

1 .当unity打包android的时候,未设置keystore ,会读取默认的keystore,具体为 :

代码是 : 

                return (Application.platform == RuntimePlatform.WindowsEditor) ?
                    System.Environment.GetEnvironmentVariable("HOMEDRIVE") + System.Environment.GetEnvironmentVariable("HOMEPATH") + @"\.android\debug.keystore" :
                    System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + @"/.android/debug.keystore";

对应的文件工程为 :

 



[2]Unity 的一些引用关系,比如说在Hierarchy界面中,找到引用: http://answers.unity3d.com/questions/648164/how-can-i-find-all-references-to-an-object-in-the.html  一个博客,打包可以使用 editorUtlity.collectReferences()收集依赖关系。http://answers.unity3d.com/questions/321615/code-to-mimic-find-references-in-scene.html#answer-933352

//  找到物品的引用关系,主要是通过
    [MenuItem("CONTEXT/Component/Find references to this")]
    private static void FindReferences(MenuCommand data)
    {
        Object context = data.context;
        if (context)
        {
            var comp = context as Component;
            if (comp) 
                FindReferencesTo(comp);
        }
    }


    [MenuItem("Assets/Find references to this")]
    private static void FindReferencesToAsset(MenuCommand data)
    {
        var selected = Selection.activeObject;
        if (selected)
            FindReferencesTo(selected);
    }


    private static void FindReferencesTo(Object to)
    {
        var referencedBy = new List<Object>();
        var allObjects = Object.FindObjectsOfType<GameObject>();
        for (int j = 0; j < allObjects.Length; j++)
        {
            var go = allObjects[j];


            if (PrefabUtility.GetPrefabType(go) == PrefabType.PrefabInstance)
            {
                if (PrefabUtility.GetPrefabParent(go) == to)
                {
                    Debug.Log(string.Format("referenced by {0}, {1}", go.name, go.GetType()), go);
                    referencedBy.Add(go);
                }
            }


            var components = go.GetComponents<Component>();
            for (int i = 0; i < components.Length; i++)
            {
                var c = components[i];
                if (!c) continue;


                var so = new SerializedObject(c);
                var sp = so.GetIterator();


                while (sp.NextVisible(true))
                    if (sp.propertyType == SerializedPropertyType.ObjectReference)
                    {
                        if (sp.objectReferenceValue == to)
                        {
                            Debug.Log(string.Format("referenced by {0}, {1}", c.name, c.GetType()), c);
                            referencedBy.Add(c.gameObject);
                        }
                    }
            }
        }
        //表示是否存在某一个元素
        if (referencedBy.Any())
            Selection.objects = referencedBy.ToArray();
        else Debug.Log("no references in scene");
    }


[3]unity的存储格式,可以强制把场景等序列化信息改成.tex存储,这样的话,就能用.txt查看场景信息了。具体是editor->project setting ->editor ->Asset serialization ->force text、

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值