Example #1
0
        public override void YamlInit(YamlDataContext context)
        {
            base.YamlInit(context);

            var p = YamlObjectUtil.GetMappingValueNode(YamlNode);

            if (p == null)
            {
                return;
            }
            NameNode       = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(p, "m_Name");
            ComponmentNode = YamlObjectUtil.SearchMappingChildNode <YamlSequenceNode>(p, "m_Component");

            Componments = new List <YamlComponment>();

            foreach (var c in ComponmentNode.Children)
            {
                YamlMappingNode child = c as YamlMappingNode;
                if (child == null)
                {
                    continue;
                }
                YamlKeyLocalRef r  = new YamlKeyLocalRef(child);
                YamlUnityObject yo = null;
                if (context.ObjectIdMap.TryGetValue(r.RefId, out yo))
                {
                    Componments.Add(yo as YamlComponment);
                }
            }
            Transofrm = GetComponment <YamlTransform>();
        }
Example #2
0
        public YamlGradient(YamlMappingNode mainNode)
        {
            /*
             * foreach (var pair in mainNode.Children)
             * {
             *  Debug.LogWarning(pair.Key + " @ " + pair.Value);
             * }
             */
            MainNode         = mainNode;
            NumColorKeysNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, "m_NumColorKeys");
            NumAlphaKeysNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, "m_NumAlphaKeys");
            int length = MaxKeyLength;

            ColorList        = new List <YamlColor>(length);
            CtimeKeyListNode = new List <YamlScalarNode>(length);
            AtimeKeyListNode = new List <YamlScalarNode>(length);
            for (int i = 0; i < length; i++)
            {
                string key    = "key" + i;
                string akey   = "atime" + i;
                string ckey   = "ctime" + i;
                var    kcNode = YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(mainNode, key);
                var    cNode  = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, ckey);
                var    aNode  = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, akey);
                ColorList.Add(new YamlColor(kcNode));
                CtimeKeyListNode.Add(cNode);
                AtimeKeyListNode.Add(aNode);
            }
        }
Example #3
0
        public void ModifyNode(string kName, string v)
        {
            var p = YamlObjectUtil.GetMappingValueNode(YamlNode);

            if (p == null)
            {
                return;
            }
            YamlNode node = null;

            if (p.Children.TryGetValue(kName, out node))
            {
                YamlScalarNode scal = node as YamlScalarNode;
                if (scal == null)
                {
                    return;
                }
                string ori = scal.Value;
                scal.Value = v;
                Debug.Log(string.Format("{0} : value modify : {1}->{2}", kName, ori, v));
            }
            else
            {
                Debug.LogError("modify node error: " + kName);
            }
        }
Example #4
0
        public override void YamlInit(YamlDataContext context)
        {
            base.YamlInit(context);
            var p = YamlObjectUtil.GetMappingValueNode <YamlMappingNode>(YamlNode);

            if (p != null)
            {
                ChildrenNode = YamlObjectUtil.SearchMappingChildNode <YamlSequenceNode>(p, "m_Children");
            }
            var fatherNode = YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(p, "m_Father");

            //Debug.LogError(fatherNode);
            Father = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(fatherNode, "fileID");

            Children = new List <YamlTransform>();
            foreach (YamlMappingNode cn in ChildrenNode)
            {
                var             c  = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(cn, "fileID");
                YamlUnityObject yo = null;
                if (context.ObjectIdMap.TryGetValue(c.Value, out yo))
                {
                    //Debug.LogWarning("ADD CHILD :" + yo.ObjectName + " => " +ObjectName);
                    Children.Add(yo as YamlTransform);
                }
            }
        }
Example #5
0
        public YamlKeyLocalRef(YamlMappingNode node)
        {
            var p = YamlObjectUtil.GetMappingValueNode <YamlMappingNode>(node);

            if (p != null)
            {
                RefIdNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(p, "fileID");
            }
        }
Example #6
0
        public string GetAttachId()
        {
            //解析出ATTACH ID
            //Debug.LogWarning(YamlNode.ToString());
            string attachId = YamlNode.Children.First().Value["m_GameObject"]["fileID"].ToString();

            attachId = YamlObjectUtil.GetContentWithoutBrace(attachId);
            //Debug.LogWarning(attachId);
            return(attachId);
        }
Example #7
0
 public YamlParticleInitialModule(YamlMappingNode mainNode)
 {
     InitialModuleNode = mainNode;
     StartLifeTime     = new YamlMinMaxCurve(GetNode("startLifetime"));
     StartSpeed        = new YamlMinMaxCurve(GetNode("startSpeed"));
     //color...
     StartColor          = new YamlMinMaxGradient(GetNode("startColor"));
     StartSize           = new YamlMinMaxCurve(GetNode("startSize"));
     StartRotationX      = new YamlMinMaxCurve(GetNode("startRotationX"));
     StartRotationY      = new YamlMinMaxCurve(GetNode("startRotationY"));
     StartRotation       = new YamlMinMaxCurve(GetNode("startRotation"));
     Rotation3DNode      = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(InitialModuleNode, "rotation3D");
     MaxNumParticlesNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(InitialModuleNode, "maxNumParticles");
 }
Example #8
0
 public YamlMinMaxGradient(YamlMappingNode mainNode)
 {
     /*
      * foreach (var pair in mainNode.Children)
      * {
      *  Debug.LogWarning(pair.Key + " @ " + pair.Value);
      * }
      * Debug.LogWarning("=================");
      */
     MainNode        = mainNode;
     MaxGradient     = new YamlGradient(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(mainNode, "maxGradient"));
     MinGradient     = new YamlGradient(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(mainNode, "minGradient"));
     MinColor        = new YamlColor(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(mainNode, "minColor"));
     MaxColor        = new YamlColor(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(mainNode, "maxColor"));
     MinMaxStateNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, "minMaxState");
 }
Example #9
0
        public override void YamlInit(YamlDataContext context)
        {
            base.YamlInit(context);
            var p = YamlObjectUtil.GetMappingValueNode(YamlNode);

            if (p == null)
            {
                return;
            }
            YamlNode node = null;

            if (p.Children.TryGetValue("InitialModule", out node))
            {
                InitialModuleNode = node as YamlMappingNode;
                InitialModule     = new YamlParticleInitialModule(InitialModuleNode);
            }
            StartDelay      = new YamlMinMaxCurve(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(p, "startDelay"));
            PrewarmNode     = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(p, "prewarm");
            LengthInSecNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(p, "lengthInSec");
        }
Example #10
0
        public string GetNodeString(string kName)
        {
            var p = YamlObjectUtil.GetMappingValueNode(YamlNode);

            if (p == null)
            {
                return("");
            }
            YamlNode node = null;

            if (p.Children.TryGetValue(kName, out node))
            {
                YamlScalarNode scal = node as YamlScalarNode;
                if (scal == null)
                {
                    return("");
                }
                return(scal.Value);
            }
            return("");
        }
Example #11
0
 //16进制转成10进制 RGBA
 public YamlColor(YamlMappingNode mainNode)
 {
     ColorNode = YamlObjectUtil.SearchMappingChildNode <YamlScalarNode>(mainNode, "rgba");
 }
Example #12
0
 public YamlMappingNode GetNode(string key)
 {
     return(YamlObjectUtil.SearchMappingChildNode <YamlMappingNode>(InitialModuleNode, key));
 }
Example #13
0
        private void Parse(YamlStream yaml, List <YamlObjectInfo> infoList, List <YamlMappingNode> nodeList)
        {
            string rootGameObjectId = "";

            DataContext = new YamlDataContext();
            //--解析 YAML 文件-- 缓存所有对象--
            Yaml     = yaml;
            InfoList = infoList;
            NodeList = nodeList;
            int length = Mathf.Min(infoList.Count, nodeList.Count);

            for (int i = 0; i < length; i++)
            {
                string typeStr;
                try
                {
                    typeStr = nodeList[i].Children.First().Key.ToString();
                }
                catch (Exception)
                {
                    typeStr = "error parse type -- list node";
                    foreach (var pair in nodeList[i].Children)
                    {
                        Debug.LogWarning(pair.Key + " : " + pair.Value);
                    }
                }
                YamlUnityObject yo = YamlObjectFactory.Create(typeStr);
                if (yo != null)
                {
                    yo.SetLocalInfo(infoList[i].TypeId, infoList[i].LocalId);
                    yo.SetYamlNode(nodeList[i]);
                    ObjectIdMap.Add(yo.LocalId, yo);
                }
                if (typeStr == "Prefab")
                {
                    //是prefab!记录一下ID
                    var             p = YamlObjectUtil.GetMappingValueNode(nodeList[i]);
                    YamlMappingNode r = YamlObjectUtil.SearchMappingChildNode(p, "m_RootGameObject") as YamlMappingNode;
                    if (r != null)
                    {
                        rootGameObjectId = YamlObjectUtil.SearchMappingChildNode(r, "fileID").ToString();
                    }
                    //Debug.LogWarning("root gameobject = " + rootGameObjectId);
                }
            }
            //---重新关联组件对象---
            foreach (var pair in ObjectIdMap)
            {
                //Debug.Log(string.Format("id:{0}, object:{1}", pair.Key, pair.Value.TypeName));
                var type = pair.Value.GetType();
                var obj  = pair.Value;
                if (type != typeof(YamlGameObject))
                {
                    string attachId = obj.GetAttachId(); //找到attachId
                    try
                    {
                        obj.SetAttachGameObject(ObjectIdMap[attachId] as YamlGameObject);
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e);
                    }
                }
                else
                {
                    obj.SetAttachGameObject(obj as YamlGameObject);
                }
            }
            DataContext.ObjectIdMap = ObjectIdMap;
            //--关联结束后,初始化GOMEOBJECT--
            foreach (var pair in ObjectIdMap)
            {
                var go = pair.Value as YamlGameObject;
                if (go != null)
                {
                    go.GameObjectInit(DataContext);
                }
            }

            //--设置prefab的根gameobject
            if (!string.IsNullOrEmpty(rootGameObjectId))
            {
                RootGameObject = ObjectIdMap[rootGameObjectId] as YamlGameObject;
            }
            RootGameObject.Transofrm.RootTransofrmInit(DataContext);
        }