private GameObject AddImageGroup(string prefabName) { GameObject gameObject = null; // get parent container for images. if it doesn't, add it. if (HeroKitDatabase.PersistentObjectDictionary.ContainsKey(prefabName)) { gameObject = HeroKitDatabase.GetPersistentObject(prefabName); } else { // add image to scene if it doesn't already exist GameObject template = Resources.Load <GameObject>("Hero Templates/Components/" + prefabName); if (template == null) { Debug.LogError("Can't add dialog box to scene because template for " + prefabName + " does not exist."); } gameObject = UnityEngine.Object.Instantiate(template, new Vector3(), new Quaternion()); gameObject.name = prefabName; // add the object to the game object dictionary HeroKitDatabase.AddPersistentObject(prefabName, gameObject); // make it persistent HeroKitObject imageHKO = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject); if (imageHKO == null) { Debug.LogError("Can't make dialog box persistent because hero kit object component is missing."); } else { MakePersistent makePersistent = new MakePersistent(); makePersistent.ExecuteOnTarget(imageHKO); } } return(gameObject); }
// This is used by HeroKitCommon.GetAction() to add this action to the ActionDictionary. Don't delete! public static MakePersistent Create() { MakePersistent action = new MakePersistent(); return(action); }