Exemple #1
0
        internal void ObjectProcessComponent(int index, LineTypes.Component line, IParentObject obj, Stack <GameObject> objectStack, Stack <ParserContext> contextStack, ParserContext context)
        {
            #region Object context
            if (context == this.objectContext)
            {
                switch (index)
                {
                case 0:
                case 2:
                    return;

                case 1:
                    MeshFilter   filter   = objectStack.Peek().AddComponent <MeshFilter>();
                    MeshRenderer renderer = objectStack.Peek().AddComponent <MeshRenderer>();
                    filter.mesh       = Utility.MeshHelper.GetQuad();
                    renderer.material = new Material(Shader.Find("Standard"));
                    return;
                }
            }
            #endregion

            if (context == this.objectContext.Components[2].context)
            {
                // COLLIDER

                // todo: this
            }

            // other components that have sub-components

            throw new Exception("Invalid member in parsed lines list");
        }
Exemple #2
0
 internal virtual void ProcessComponent(int index, LineTypes.Component line, IParentObject obj, Stack <GameObject> objectStack, Stack <ParserContext> contextStack, ParserContext context)
 {
     // overload with switch-case and handle functionalities
     throw new Exception("Invalid member in parsed lines list");
 }
Exemple #3
0
        private void ProcessLine(IParentObject rootObject, Stack <ParserContext> contextStack, Stack <GameObject> objectStack, IParserLine tempLine)
        {
            LineType      type           = tempLine.GetType();
            ParserContext currentContext = contextStack.Peek();

            int index = -1;

            switch (type)
            {
            case LineType.Property:
                LineTypes.Property lineProperty = (LineTypes.Property)tempLine;

                for (int i = 0; i < currentContext.Properties.Length; i++)
                {
                    if (currentContext.Properties[i].name == lineProperty.name)
                    {
                        index = i;
                        break;
                    }
                }
                if (index == -1)
                {
                    throw new Exception("Invalid member in parsed lines list");
                }
                ProcessProperty(index, lineProperty, rootObject, objectStack, currentContext);
                break;

            case LineType.Component:
                LineTypes.Component lineComponent = (LineTypes.Component)tempLine;

                for (int i = 0; i < currentContext.Components.Length; i++)
                {
                    if (currentContext.Components[i].name == lineComponent.name)
                    {
                        index = i;
                        break;
                    }
                }
                if (index == -1)
                {
                    throw new Exception("Invalid member in parsed lines list");
                }
                ProcessComponent(index, lineComponent, rootObject, objectStack, contextStack, currentContext);
                contextStack.Push(currentContext.Components[index].context);
                break;

            case LineType.Object:
                LineTypes.Object lineObject = (LineTypes.Object)tempLine;

                GameObject tempGO = new GameObject();
                tempGO.name = lineObject.name;
                tempGO.SetActive(false);

                if (objectStack.Count > 0)
                {
                    tempGO.transform.parent = objectStack.Peek().transform;
                }
                rootObject.AssignChild(tempGO);

                objectStack.Push(tempGO);
                contextStack.Push(this.objectContext);
                break;

            case LineType.ObjectClose:
            case LineType.ComponentClose:
                contextStack.Pop();
                break;

            default:
                throw new System.Exception("Invalid line type in parsed lines list");
            }
        }