Exemplo n.º 1
0
        // 创建实例.
        public override GKToyBaseOverlord _CreateData(string path)
        {
            // 生成数据源.
            var       obj   = ScriptableObject.CreateInstance <GKToyExternalData>();
            GKToyData tData = new GKToyData();

            obj.data = tData.Clone() as GKToyData;
            GKEditor.CreateAsset(obj, path);
            var externalData = AssetDatabase.LoadMainAssetAtPath(path) as GKToyExternalData;

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

            string myName = Path.GetFileNameWithoutExtension(path);

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

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

            // 初始化首次数据.
            GKToyMakerChapterInfo.Create(this, position.min, ToyMakerBase._minWidth, ToyMakerBase._minHeight, _GetTaskLocalization("Chapter Infomation"), tmpOverload, go);
            return(tmpOverload);
        }
Exemplo n.º 2
0
        static public void AdjustNodeData(GameObject go, Vector3 pos, Vector4 offest, Vector2 size, UIAncherType ancher = UIAncherType.MiddleCenter)
        {
            var tran = GK.GetOrAddComponent <RectTransform>(go);

            if (null != tran)
            {
                tran.sizeDelta     = size;
                tran.pivot         = new Vector2(0.5f, 0.5f);
                tran.localPosition = Vector3.zero;

                if (UIAncherType.MiddleCenter == ancher)
                {
                    tran.anchorMax = new Vector2(0.5f, 0.5f);
                    tran.anchorMin = new Vector2(0.5f, 0.5f);

                    float x = pos.x - (UIController.width - size.x) * 0.5f;
                    float y = UIController.height * 0.5f - (UIController.height - pos.y - size.y * 0.5f);

                    tran.localPosition = new Vector3(x, y, 0);
                }
                else if (UIAncherType.FullScree == ancher)
                {
                    tran.anchorMax = new Vector2(1, 1);
                    tran.anchorMin = new Vector2(0, 0);
                    tran.offsetMin = new Vector2(offest.x, offest.y);
                    tran.offsetMax = new Vector2(offest.z, offest.w);
                }
            }
        }
Exemplo n.º 3
0
 static void _Init(T instance)
 {
     if (instance)
     {
         instance.gameObject.SetActive(true);
         RectTransform rt = GK.GetOrAddComponent <RectTransform>(instance.gameObject);
         rt.sizeDelta        = Vector2.zero;
         rt.anchoredPosition = Vector3.zero;
         UIController.AddUI(instance);
         instance.OnOpen();
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        static public GKUIEventTriggerListener Get(GameObject go)
        {
            GKUIEventTriggerListener listener = GK.GetOrAddComponent <GKUIEventTriggerListener>(go);

            return(listener);
        }