Exemplo n.º 1
0
    public static void ResetAllHangPoint()
    {
        HangPointSet hangPointSet = new HangPointSet();
        var          guids        = AssetDatabase.FindAssets("t:GameObject", new string[] { "Assets/ResourceEx/Prefab" });
        int          count        = guids.Length;

        for (int i = 0; i < count; i++)
        {
            EditorUtility.DisplayProgressBar("更新挂点数据", "正在更新挂点数据(" + i + "/" + count + ")", i / (float)count);
            string        goPath        = AssetDatabase.GUIDToAssetPath(guids[i]);
            GameObject    gameObject    = AssetDatabase.LoadAssetAtPath <GameObject>(goPath);
            HangPointView hangPointView = gameObject.GetComponent <HangPointView>();
            if (hangPointView != null)
            {
                HangPointItem hangPointItem = new HangPointItem();
                hangPointItem.path = goPath;
                FindHangPoint(gameObject.transform, gameObject.transform, null, null, hangPointItem);
                hangPointSet.mLstHangPointItem.Add(hangPointItem);
            }
        }
        NEUtil.SerializerObject(HangPointCfgSys.HangPointPath, hangPointSet);
        EditorUtility.ClearProgressBar();
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
Exemplo n.º 2
0
    private void LoadData()
    {
        TextAsset textAsset = AssetDatabase.LoadAssetAtPath <TextAsset>(HangPointCfgSys.HangPointPath);

        m_cHangPointSet = null;
        if (textAsset != null)
        {
            var bytes = textAsset.bytes;
            m_cHangPointSet = NEUtil.DeSerializerObjectFromBuff(bytes, typeof(HangPointSet)) as HangPointSet;
        }
        if (m_cHangPointSet == null)
        {
            m_cHangPointSet = new HangPointSet();
        }

        HangPointView hangPoint  = (HangPointView)target;
        PrefabType    prefabType = PrefabUtility.GetPrefabType(hangPoint.gameObject);

        Debug.Log(prefabType);
        m_bIsPrefab = (prefabType == PrefabType.Prefab || prefabType == PrefabType.PrefabInstance);
        if (m_bIsPrefab)
        {
            UnityEngine.Object prefab = null;
            if (prefabType == PrefabType.PrefabInstance)
            {
                prefab = PrefabUtility.GetPrefabParent(hangPoint.gameObject);
            }
            else
            {
                prefab = hangPoint.gameObject;
            }
            Debug.Log(prefab);
            if (m_cHangPointSet != null && prefab != null)
            {
                string path = AssetDatabase.GetAssetPath(prefab);
                Debug.Log("path:" + path);
                m_cHangPointItem = m_cHangPointSet.GetHangPointItem(path);
                if (m_cHangPointItem == null)
                {
                    m_cHangPointItem      = new HangPointItem();
                    m_cHangPointItem.path = path;
                    m_cHangPointSet.mLstHangPointItem.Add(m_cHangPointItem);
                }
            }
        }
    }
Exemplo n.º 3
0
 void OnDisable()
 {
     m_cHangPointSet = null;
 }