Esempio n. 1
0
    private void ProcessSelectedSceneNodes()
    {
        Dictionary <string, Color32[, ]> samplers = new Dictionary <string, Color32[, ]>();

        foreach (var pair in m_Samplers)
        {
            var bitmap = System.Drawing.Image.FromFile(pair.Value) as Bitmap;
            if (null != bitmap)
            {
                var colors = new Color32[bitmap.Width, bitmap.Height];
                for (int i = 0; i < bitmap.Width; ++i)
                {
                    for (int j = 0; j < bitmap.Height; ++j)
                    {
                        System.Drawing.Color c = bitmap.GetPixel(i, j);
                        colors[i, j] = new Color32(c.R, c.G, c.B, c.A);
                    }
                }
                samplers.Add(pair.Key, colors);
            }
        }
        foreach (GameObject obj in Selection.gameObjects)
        {
            TerrainEditUtility.Process(obj, m_DslFile, samplers, m_Caches);
            Debug.Log("handle " + obj.name);
        }
        EditorUtility.DisplayDialog("提示", "处理完成", "ok");
    }
    private void ProcessSelectedSceneNodes()
    {
        Dictionary <string, Color32[, ]> samplers = new Dictionary <string, Color32[, ]>();

        foreach (var pair in m_Samplers)
        {
            var bitmap = AssetDatabase.LoadAssetAtPath <Texture2D>(pair.Value);
            if (null != bitmap)
            {
                var colors = new Color32[bitmap.width, bitmap.height];
                for (int i = 0; i < bitmap.width; ++i)
                {
                    for (int j = 0; j < bitmap.height; ++j)
                    {
                        Color c = bitmap.GetPixel(i, j);
                        colors[i, j] = c;
                    }
                }
                samplers.Add(pair.Key, colors);
            }
        }
        List <ObjectInfo> objects = new List <ObjectInfo>();

        foreach (GameObject obj in Selection.gameObjects)
        {
            TerrainEditUtility.Process(obj, m_DslFile, samplers, m_Caches, objects);
            Debug.Log("handle " + obj.name);
        }
        EditorUtility.DisplayDialog("提示", "处理完成", "ok");
    }