// --------------------------------------------------------------------------------- public static bool IsInUse(iCS_MonoBehaviourImp monoBehaviour) { if (IStorage == null) { return(false); } return(IStorage.VisualScript == monoBehaviour); }
// --------------------------------------------------------------------------------- public static bool IsSameVisualScript(iCS_MonoBehaviourImp monoBehaviour, iCS_IStorage iStorage) { if (monoBehaviour == null || iStorage == null) { return(false); } if (iStorage.iCSMonoBehaviour == monoBehaviour) { return(true); } return(false); }
// ---------------------------------------------------------------------- public static void PasteIntoGraph(iCS_MonoBehaviourImp sourceMonoBehaviour, iCS_EngineObject sourceRoot, iCS_IStorage iStorage, iCS_EditorObject parent, Vector2 globalPos) { if (!IsCreationAllowed()) { return; } OpenTransaction(iStorage); iCS_EditorObject pasted = null; try { iStorage.AnimateGraph(null, _ => { if (parent.IsFoldedInLayout || parent.IsIconizedInLayout) { parent.Unfold(); } iCS_IStorage srcIStorage = new iCS_IStorage(sourceMonoBehaviour); iCS_EditorObject srcRoot = srcIStorage.EditorObjects[sourceRoot.InstanceId]; pasted = iStorage.Copy(srcRoot, srcIStorage, parent, globalPos, iStorage); if (pasted != null) { if (pasted.IsUnfoldedInLayout) { pasted.Fold(); } iStorage.SelectedObject = pasted; iStorage.ForcedRelayoutOfTree(); } } ); } catch (System.Exception) { CancelTransaction(iStorage); return; } if (pasted != null) { SystemEvents.AnnounceVisualScriptElementAdded(pasted); } CloseTransaction(iStorage, "Add Prefab " + sourceRoot.RawName); }
// ---------------------------------------------------------------------- void PasteIntoGraph(Vector2 point, iCS_MonoBehaviourImp sourceMonoBehaviour, iCS_EngineObject sourceRoot) { if (sourceRoot == null) { return; } iCS_EditorObject validParent = GetValidParentNodeUnder(point, sourceRoot); if (validParent == null) { var node = IStorage.GetNodeAt(point); if (node == null && IStorage.IsEmptyBehaviour) { EditorUtility.DisplayDialog("Function or Event Handler required !", "You must create a function or event handler to paste into.", "Cancel"); return; } else { EditorUtility.DisplayDialog("Operation Aborted", "Unable to find a suitable parent to paste into !!!", "Cancel"); return; } } iCS_UserCommands.PasteIntoGraph(sourceMonoBehaviour, sourceRoot, IStorage, validParent, point); }