Exemple #1
0
        /// <summary>
        /// 设置ID区间完毕后,设置实例
        /// </summary>
        /// <param name="window"></param>
        public void _ModalClosed(GKUIModalWindow window)
        {
            GKToyMakerChapterInfo info = window as GKToyMakerChapterInfo;

            if (info == null)
            {
                return;
            }
            if (window.Result != WindowResult.Ok)
            {
                info.Focus();
                return;
            }
            info.overlord.internalData.data.curLiteralId = info.overlord.internalData.data.minLiteralId;
            Selection.activeGameObject = info.obj;
            _ResetSelected(info.overlord);
            GKToyNode node = new GKToyStart(_GenerateGUID(CurNodeIdx++));
            Type      type = node.GetType();

            node.className = string.Format("{0}.{1}", type.Namespace, type.Name);
            node.pos.x     = (_contentScrollPos.x + ToyMakerBase._minWidth * 0.5f) / Scale;
            node.pos.y     = (_contentScrollPos.y + ToyMakerBase._minHeight * 0.5f) / Scale;
            _CreateNode(node);
            _Changed();
            _overlord.Save();
            _overlord.Backup();
            _overlord.SavePrefab(ToyMakerBase._defaultOverlordPath);
        }
Exemple #2
0
        GameObject _CreateDialogueData(string path, int taskId, string dfgType)
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            // 生成数据源.
            var       obj   = ScriptableObject.CreateInstance <GKToyExternalData>();
            GKToyData tData = new GKToyData();

            obj.data = tData.Clone() as GKToyData;
            string assetPath = string.Format("{0}{1}_{2}.Asset", path, dfgType, taskId);

            GKEditor.CreateAsset(obj, assetPath);
            var externalData = AssetDatabase.LoadMainAssetAtPath(assetPath) as GKToyExternalData;

            if (null == externalData)
            {
                return(null);
            }

            string myName = string.Format("{0}_{1}", dfgType, taskId);

            // 创建宿主.
            GameObject go          = new GameObject();
            var        tmpOverload = GK.GetOrAddComponent <GKToyBaseOverlord>(go);

            tmpOverload.internalData           = externalData;
            tmpOverload.name                   = myName;
            tmpOverload.internalData.data.name = myName;

            // 初始化首次数据.
            GKToyNode node = new GKToyStart(_GenerateGUID(tmpOverload.internalData.data.nodeGuid++));
            Type      type = node.GetType();

            node.className = string.Format("{0}.{1}", type.Namespace, type.Name);
            node.pos.x     = (_contentScrollPos.x + ToyMakerBase._minWidth * 0.5f) / Scale;
            node.pos.y     = (_contentScrollPos.y + ToyMakerBase._minHeight * 0.5f) / Scale;
            node.id        = node.ID;
            node.nodeType  = NodeType.Action;
            node.name      = "开始-1";
            node.Init(tmpOverload);
            node.comment = "";
            tmpOverload.internalData.data.nodeLst.Add(node.id, node);
            node           = new GKToyEnd(_GenerateGUID(_GenerateGUID(tmpOverload.internalData.data.nodeGuid++)));
            type           = node.GetType();
            node.className = string.Format("{0}.{1}", type.Namespace, type.Name);
            node.pos.x     = -10;
            node.pos.y     = -10;
            node.id        = node.ID;
            node.nodeType  = NodeType.Action;
            node.name      = "结束-2";
            node.Init(tmpOverload);
            node.comment = "";
            tmpOverload.internalData.data.nodeLst.Add(node.id, node);
            tmpOverload.Save();
            tmpOverload.Backup();
            string     prefabPath = string.Format("{0}{1}_{2}.prefab", path, dfgType, taskId);
            GameObject prefab;

            if (!File.Exists(prefabPath))
            {
                prefab = PrefabUtility.CreatePrefab(prefabPath, go);
            }
            else
            {
                prefab = AssetDatabase.LoadAssetAtPath <GameObject>(prefabPath);
                prefab = PrefabUtility.ReplacePrefab(go, prefab);
            }
            DestroyImmediate(go);
            return(prefab);
        }