ProcessPrefab() public method

public ProcessPrefab ( ) : void
return void
Ejemplo n.º 1
0
    public void SavePrefabInformation(GeneratablePrefab prefab, bool shouldRecomputePrefabInformation, bool replaceOld = true)
    {
        const string resPrefix = "Resources/";
        string assetPath = AssetDatabase.GetAssetPath(prefab);
        if (string.IsNullOrEmpty(assetPath))
            return;
        string newFileName = assetPath.Substring(assetPath.LastIndexOf(resPrefix) + resPrefix.Length);
        newFileName = newFileName.Substring(0, newFileName.LastIndexOf("."));
        int replaceIndex = -1;
        if (replaceOld)
        {
            replaceIndex = availablePrefabs.FindIndex( (PrefabDatabase.PrefabInfo testInfo)=>{
                return testInfo.fileName == newFileName;
            });
            if (replaceIndex >= 0)
                availablePrefabs.RemoveAt(replaceIndex);
        }

        if (prefab.shouldUse)
        {
            if (shouldRecomputePrefabInformation)
                prefab.ProcessPrefab();
            PrefabDatabase.PrefabInfo newInfo = new PrefabDatabase.PrefabInfo();
            newInfo.fileName = newFileName;
            newInfo.complexity = prefab.myComplexity;
            newInfo.bounds = prefab.myBounds;
            newInfo.isLight = prefab.isLight;
            newInfo.anchorType = prefab.attachMethod;
            foreach(GeneratablePrefab.StackableInfo stackRegion in prefab.stackableAreas)
                newInfo.stackableAreas.Add(stackRegion);
            if (replaceIndex < 0)
                availablePrefabs.Add(newInfo);
            else
                availablePrefabs.Insert(replaceIndex, newInfo);
        }
        EditorUtility.SetDirty(this);
    }
Ejemplo n.º 2
0
    public void SavePrefabInformation(GeneratablePrefab prefab, string assetPath, bool shouldRecomputePrefabInformation, bool replaceOld = true)
    {
        /*
         * Saves the prefab information in "prefabs" property of PrefabDatabase prefab.
         */
        string newFileName = "";
        if (assetPath == null) {
            const string resPrefix = "Resources/";
            assetPath = AssetDatabase.GetAssetPath (prefab);
            if (string.IsNullOrEmpty (assetPath))
                return;
            newFileName = assetPath.Substring (assetPath.LastIndexOf (resPrefix) + resPrefix.Length);
            newFileName = newFileName.Substring (0, newFileName.LastIndexOf ("."));
        } else {
            if (!(assetPath.ToLowerInvariant ().Contains ("http://"))) {
                const string resPrefix = BUNDLES_SUBPATH;
                string currentPath = Directory.GetCurrentDirectory ();
                newFileName = Path.Combine (currentPath, assetPath);
            } else {
                newFileName = assetPath;
            }
        }
        int replaceIndex = -1;
        if (replaceOld) {
            replaceIndex = prefabs.FindIndex ((PrefabInfo testInfo) => {
                return testInfo.fileName == newFileName;
            });
            if (replaceIndex >= 0)
                prefabs.RemoveAt (replaceIndex);
        }

        if (prefab.shouldUse) {

            if (shouldRecomputePrefabInformation)
                prefab.ProcessPrefab ();
            PrefabInfo newInfo = new PrefabInfo ();
            newInfo.fileName = newFileName;
            newInfo.complexity = prefab.myComplexity;
            newInfo.bounds = prefab.myBounds;
            newInfo.isLight = prefab.isLight;
            newInfo.anchorType = prefab.attachMethod;
            foreach (GeneratablePrefab.StackableInfo stackRegion in prefab.stackableAreas)
                newInfo.stackableAreas.Add (stackRegion);
            if (replaceIndex < 0)
                prefabs.Add (newInfo);
            else
                prefabs.Insert (replaceIndex, newInfo);
        }
        EditorUtility.SetDirty (this);
    }