/// <summary> /// Get a plugin instance /// </summary> /// <param name="sc"></param> /// <param name="atomUid"></param> /// <param name="pluginName"></param> /// <returns></returns> public static JSONStorable GetPluginStorable(this SuperController sc, string atomUid, string pluginName) { if (atomUid == null || pluginName == null) { return(null); } return(sc.GetAtomByUid(atomUid)?.GetPluginStorable(pluginName)); }
/// <summary> /// Get a FreeControllerV3 by name /// </summary> /// <param name="sc"></param> /// <param name="atomUid"></param> /// <param name="controllerName"></param> /// <returns></returns> public static FreeControllerV3 GetFreeController(this SuperController sc, string atomUid, string controllerName) { if (atomUid == null || controllerName == null) { return(null); } return(sc.GetAtomByUid(atomUid)?.freeControllers?.Where((fc) => fc.name.Equals(controllerName)).FirstOrDefault()); }
IEnumerator Load(JSONClass saveObject) { yield return(new WaitForSeconds(2.0f)); JSONArray savedNodes = saveObject["nodes"].AsArray; JSONArray savedTransitions = saveObject["transitions"].AsArray; for (int i = 0; i < savedNodes.Count; i++) { Atom a = sc.GetAtomByUid(savedNodes[i]["atom"].Value); if (a == null) { SuperController.LogError("Animation graph could not find the atom named " + savedNodes[i]["atom"].Value); continue; } AnimationPattern ap = a.GetStorableByID("AnimationPattern") as AnimationPattern; if (ap == null) { SuperController.LogError(a.name + " is not an animation pattern"); continue; } CreateNode(ap); } if (nodes.Count > 0) { root = nodes[0]; } for (int i = 0; i < savedTransitions.Count; i++) { JSONClass transitionData = savedTransitions[i].AsObject; string startName = transitionData["start"].Value; string endName = transitionData["end"].Value; Atom a = sc.GetAtomByUid(startName); Atom b = sc.GetAtomByUid(endName); if (a == null) { SuperController.LogError(startName + " atom was not found"); continue; } if (b == null) { SuperController.LogError(endName + " atom was not found"); continue; } Transition t = CreateTransition(a, b); if (t != null) { Node nodeA = FindNodeFromAtom(a); if (nodeA != null) { nodeA.transitions.Add(t); } } } }