コード例 #1
0
ファイル: PrefabEditor.cs プロジェクト: yqxflong/mh_3drpg
    public bool CommitPrefab()
    {
        bool commited = false;

        if (this.Source == null)
        {
            Debug.Log("ERROR: No Source Prefab");
        }
        else if (this.Target == null)
        {
            Debug.Log("ERROR: No Target Prefab Instance");
        }
        else
        {
            RegisterUndo("Commiting Prefab");
            var result = PrefabUtility.ReplacePrefab(this.Target.gameObject, this.Source.gameObject, ReplacePrefabOptions.ReplaceNameBased);
            if (result != null)
            {
                string msg = string.Format("Saved {0}", this.Source.name);
                EditorUtility.DisplayDialog(GetType().Name, msg, "OK");
                commited   = true;
                this.Dirty = false;
            }
            else
            {
                string msg = string.Format("Error replacing Prefab {0}", this.Source.name);
                EditorUtility.DisplayDialog(GetType().Name, msg, "OK");
            }

            LocalizationUtils.SaveDbs();
        }

        return(commited);
    }