Пример #1
0
        private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            plyVar plyVar = this.targetHandler.variables[index];

            if (plyVar != null && plyVar.ValueHandler != null)
            {
                plyVarEd plyVarEd = plyVariablesEditor.editors[plyVar.ValueHandler.GetType()];
                plyVarEd_Array.GC_Element.text = this.targetHandler.variables.Count.ToString();
                float num   = (float)(plyEdGUI.Styles.Label_RT.CalcSize(plyVarEd_Array.GC_Element).x + 5.0);
                Rect  rect2 = rect;
                rect2.width = num;
                plyVarEd_Array.GC_Element.text = index.ToString();
                GUI.Label(rect2, plyVarEd_Array.GC_Element, plyEdGUI.Styles.Label_RT);
                rect2.x     = rect2.xMax;
                rect2.width = rect.width - num;
                EditorGUI.BeginChangeCheck();
                plyVarEd.DrawEditor(rect2, this.isOnSceneObject, plyVar, this.targetVar, index);
                if (EditorGUI.EndChangeCheck())
                {
                    this.saveCallback();
                }
            }
        }
Пример #2
0
 public bool Initialize(Action onValueChangedCallback)
 {
     if (!Application.isEditor)
     {
         this.storedData = null;
     }
     if (this.dataContext == DataContext.Constant)
     {
         this.Value = this.constant.GetValue();
         if (!Application.isEditor)
         {
             this.constant = null;
         }
         return(true);
     }
     if (this.dataContext == DataContext.GlobalProperty)
     {
         this.onValueChanged          += onValueChangedCallback;
         this.property.onValueChanged += this.BoundValueChanged;
         return(true);
     }
     return(false);
 }
Пример #3
0
 public override string VarTypeName(plyVar target)
 {
     return("Vector4");
 }
Пример #4
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Vector2 plyVar_Vector = (plyVar_Vector2)target.ValueHandler;

            plyVar_Vector.storedValue = EditorGUI.Vector2Field(rect, GUIContent.none, plyVar_Vector.storedValue);
            return(false);
        }
Пример #5
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Float plyVar_Float = (plyVar_Float)target.ValueHandler;

            plyVar_Float.storedValue = EditorGUI.FloatField(rect, plyVar_Float.storedValue);
            return(false);
        }
Пример #6
0
        public override string VarTypeName(plyVar target)
        {
            plyVar_Array plyVar_Array = (plyVar_Array)target.ValueHandler;

            return("Array<" + BloxEd.PrettyTypeName(plyVar_Array.baseType, false) + ">");
        }
Пример #7
0
 public override string VarTypeName(plyVar target)
 {
     return(target.variableType.Name);
 }
Пример #8
0
        public plyVar RunAndGetVariable(Type expectedType = null)
        {
            if (this.varType == plyVariablesType.Event)
            {
                this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                if (this.v == null)
                {
                    if (base.owningBlock == null)
                    {
                        BloxBlock obj = base.paramBlocks[0];
                        expectedType = (((obj != null) ? obj.returnType : null) ?? typeof(object));
                    }
                    else if (base.fieldIdx == -1)
                    {
                        expectedType = (base.owningBlock.ContextType() ?? typeof(object));
                    }
                    else
                    {
                        Type[] array = base.owningBlock.ParamTypes();
                        expectedType = ((array == null || base.fieldIdx < 0 || base.fieldIdx >= array.Length) ? typeof(object) : (array[base.fieldIdx] ?? typeof(object)));
                    }
                    this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                    if (this.v == null)
                    {
                        base.LogError("The Event Variable [" + this.varName + "] does not exist in Event [" + base.owningEvent.screenName + "] on GameObject: " + base.owningEvent.container.name, null);
                        return(null);
                    }
                }
            }
            else if (this.varType != plyVariablesType.Blox)
            {
                if (this.varType == plyVariablesType.Object)
                {
                    GameObject gameObject = null;
                    object     obj2       = (base.paramBlocks[1] == null) ? base.owningEvent.container.gameObject : base.paramBlocks[1].Run();
                    if (obj2 != null)
                    {
                        gameObject = (obj2 as GameObject);
                        if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null)
                        {
                            Component component = obj2 as Component;
                            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                            {
                                gameObject = component.gameObject;
                            }
                        }
                    }
                    if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
                    {
                        ObjectVariables component2 = gameObject.GetComponent <ObjectVariables>();
                        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                        {
                            this.v = component2.variables.FindVariable(this.varName);
                            if (this.v == null)
                            {
                                base.LogError("The Object Variable [" + this.varName + "] does not exist on GameObject: " + gameObject.name, null);
                                return(null);
                            }
                            goto IL_0265;
                        }
                        base.LogError("Could not find ObjectVariables component on GameObject [" + gameObject.name + "] for Object Variable: " + this.varName, null);
                        return(null);
                    }
                    base.LogError("The 2nd field must be set to a target GameObject that has the Object Variable component on it with the variable named: " + this.varName, null);
                    return(null);
                }
                if (this.varType != plyVariablesType.Global)
                {
                    base.LogError("Invalid Variable Type specified. This should not happen.", null);
                    return(null);
                }
            }
            goto IL_0265;
IL_0265:
            return(this.v);
        }
Пример #9
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Color32 plyVar_Color = (plyVar_Color32)target.ValueHandler;

            plyVar_Color.storedValue = EditorGUI.ColorField(rect, plyVar_Color.storedValue);
            return(false);
        }
Пример #10
0
 public override string VarTypeName(plyVar target)
 {
     return("AnimationCurve");
 }
Пример #11
0
 public override string VarTypeName(plyVar target)
 {
     return("Prefab");
 }
Пример #12
0
 public virtual bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
 {
     return(false);
 }
Пример #13
0
 public virtual bool DrawAdvancedEditor(plyVar target, bool isOnSceneObject, Action saveCallback)
 {
     return(false);
 }
Пример #14
0
 public virtual bool DrawCreateWizard(plyVar target)
 {
     return(true);
 }
Пример #15
0
 public virtual string VarTypeName(plyVar target)
 {
     return("");
 }
Пример #16
0
 public override string VarTypeName(plyVar target)
 {
     return("Integer");
 }
Пример #17
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Bool plyVar_Bool = (plyVar_Bool)target.ValueHandler;

            plyVar_Bool.storedValue = EditorGUI.ToggleLeft(rect, plyVar_Bool.storedValue ? plyVarEd_Bool.GC_True : plyVarEd_Bool.GC_False, plyVar_Bool.storedValue);
            return(false);
        }
Пример #18
0
 public override string VarTypeName(plyVar target)
 {
     return("Boolean");
 }
Пример #19
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_AnimationCurve plyVar_AnimationCurve = (plyVar_AnimationCurve)target.ValueHandler;

            plyVar_AnimationCurve.storedValue = EditorGUI.CurveField(rect, plyVar_AnimationCurve.storedValue);
            return(false);
        }
Пример #20
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Vector4 plyVar_Vector = (plyVar_Vector4)target.ValueHandler;

            plyVar_Vector.storedValue = plyEdGUI.Vector4Field(rect, plyVar_Vector.storedValue);
            return(false);
        }
Пример #21
0
        protected override object RunBlock()
        {
            int num  = 0;
            int num2 = 0;

            try
            {
                if (base.paramBlocks[1] != null)
                {
                    num = (int)base.paramBlocks[1].Run();
                }
                if (base.paramBlocks[2] != null)
                {
                    num2 = (int)base.paramBlocks[2].Run();
                }
            }
            catch (InvalidCastException)
            {
                base.LogError("An Integer was expected in [from] and [while less].", null);
                return(null);
            }
            catch (Exception ex2)
            {
                base.LogError(ex2.Message, null);
                return(null);
            }
            if (num > num2)
            {
                base.LogError("The start value should be smaller than the end value", null);
                return(null);
            }
            plyVar plyVar = null;

            try
            {
                if (base.paramBlocks[0] != null)
                {
                    plyVar = ((Variable_Block)base.paramBlocks[0]).RunAndGetVariable(typeof(int));
                    if (plyVar != null && plyVar.ValueHandler != null && plyVar.variableType == typeof(int))
                    {
                        goto end_IL_0081;
                    }
                    base.LogError("The Variable used in [with] must be of Integer type.", null);
                    return(null);
                }
                end_IL_0081 :;
            }
            catch (InvalidCastException)
            {
                base.LogError("A Variable was expected in [with].", null);
                return(null);
            }
            catch (Exception ex4)
            {
                base.LogError(ex4.Message, null);
                return(null);
            }
            int num3 = 0;
            int num4 = num;

            while (num4 != num2)
            {
                if (plyVar != null)
                {
                    plyVar.SetValue(num4);
                }
                base.RunChildBlocks();
                if (base.flowSig == BloxFlowSignal.Break)
                {
                    base.flowSig = BloxFlowSignal.None;
                    break;
                }
                if (base.flowSig == BloxFlowSignal.Stop)
                {
                    break;
                }
                if (base.flowSig == BloxFlowSignal.Continue)
                {
                    base.flowSig = BloxFlowSignal.None;
                }
                num4++;
                num3++;
                if (num3 >= BloxGlobal.Instance.deadlockDetect)
                {
                    Debug.LogErrorFormat(base.owningEvent.container.gameObject, "Deadlock detected in Loop in Event [{0}:{1}]. Forcing break.", base.owningEvent.container.gameObject.name, base.owningEvent.screenName);
                    base.flowSig = BloxFlowSignal.Break;
                    break;
                }
            }
            return(null);
        }
Пример #22
0
 public void VariableWasAdded()
 {
     this.advVar = null;
     this.advEd  = null;
 }
Пример #23
0
 public override string VarTypeName(plyVar target)
 {
     return("Color32");
 }
Пример #24
0
 public override string VarTypeName(plyVar target)
 {
     return("GameObject");
 }
Пример #25
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Array plyVar_Array = (plyVar_Array)target.ValueHandler;

            this.targetVar       = target;
            this.targetHandler   = plyVar_Array;
            this.isOnSceneObject = isOnSceneObject;
            bool result = false;

            plyVarEd_Array.GC_Button.text = "[" + plyVar_Array.variables.Count + "] click to edit array";
            if (GUI.Button(rect, plyVarEd_Array.GC_Button, GUI.skin.label))
            {
                result = true;
                plyVarEd_Array.GC_Head.text = "Array: <b>" + target.name + "</b>";
            }
            return(result);
        }
Пример #26
0
 public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
 {
     GUI.Label(rect, "Can't edit this variable type");
     return(false);
 }
Пример #27
0
        public override CodeExpression CreateBlockCodeExpression(BloxBlockEd bdi)
        {
            Variable_Block variable_Block = (Variable_Block)bdi.b;
            plyVar         plyVar         = null;

            if (!this.UpdateBlockReturnType(bdi, ref plyVar))
            {
                Debug.LogErrorFormat("The [{0}] variable [{1}] is not defined.", variable_Block.varType, variable_Block.varName);
                return(null);
            }
            if (variable_Block.varType == plyVariablesType.Event)
            {
                if (BloxScriptGenerator.processingEvent.def.pars.Length != 0)
                {
                    BloxEventDef.Param[] pars = BloxScriptGenerator.processingEvent.def.pars;
                    for (int i = 0; i < pars.Length; i++)
                    {
                        BloxEventDef.Param param = pars[i];
                        if (param.name == variable_Block.varName)
                        {
                            bdi.sgReturnType = param.type;
                            return(new CodeVariableReferenceExpression(variable_Block.varName));
                        }
                    }
                }
                string cleanEventVariableName = BloxScriptGenerator.GetCleanEventVariableName(variable_Block.varName, false);
                if (BloxScriptGenerator.processingEvent.ev.ident == "Custom" && cleanEventVariableName.StartsWith("param") && cleanEventVariableName.Length > 5)
                {
                    int argIdx = -1;
                    if (int.TryParse(cleanEventVariableName.Substring(5), out argIdx))
                    {
                        Type type = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx];
                        if (type == null)
                        {
                            type = typeof(object);
                        }
                        BloxScriptGenerator.AddEventVariable(cleanEventVariableName, type, null, argIdx, false);
                    }
                }
                else
                {
                    Type type2 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx];
                    if (type2 == null)
                    {
                        type2 = typeof(object);
                    }
                    BloxScriptGenerator.AddEventVariable(cleanEventVariableName, type2, null, -1, false);
                }
                Type eventVariableType = BloxScriptGenerator.GetEventVariableType(cleanEventVariableName);
                if (eventVariableType != null)
                {
                    bdi.sgReturnType = eventVariableType;
                }
                return(new CodeVariableReferenceExpression(cleanEventVariableName));
            }
            if (variable_Block.varType == plyVariablesType.Blox)
            {
                CodeExpression targetObject = new CodeVariableReferenceExpression(BloxScriptGenerator.GetCleanBloxVariableName(variable_Block.varName));
                Type           type3        = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx];
                if (type3 != null)
                {
                    plyVarValueHandler valueHandler = plyVar.ValueHandler;
                    Type type4 = (valueHandler != null) ? valueHandler.GetType() : null;
                    if (type4 == typeof(plyVar_GameObject) || type4 == typeof(plyVar_Component))
                    {
                        if (typeof(GameObject).IsAssignableFrom(type3))
                        {
                            bdi.sgReturnType = type3;
                            return(new CodeMethodInvokeExpression(targetObject, "GetGameObject"));
                        }
                        if (typeof(Component).IsAssignableFrom(type3))
                        {
                            bdi.sgReturnType = type3;
                            return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject, "GetComponent", new CodeTypeReference(type3))));
                        }
                    }
                    else if (plyVar.ValueHandler.GetType() == typeof(plyVar_UnityObject))
                    {
                        bdi.sgReturnType = type3;
                        return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject, "GetObject", new CodeTypeReference(type3))));
                    }
                }
                return(new CodeMethodInvokeExpression(targetObject, "GetValue"));
            }
            if (variable_Block.varType == plyVariablesType.Object)
            {
                CodeExpression targetObject2 = BloxScriptGenerator.CreateBlockCodeExpression(bdi.paramBlocks[1], null) ?? new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "gameObject");
                targetObject2 = new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetComponent", new CodeTypeReference(typeof(ObjectVariables))));
                Type type5 = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx];
                if (type5 != null)
                {
                    if (typeof(GameObject).IsAssignableFrom(type5))
                    {
                        bdi.sgReturnType = type5;
                        return(new CodeMethodInvokeExpression(targetObject2, "GetGameObjectVarValue", new CodePrimitiveExpression(variable_Block.varName)));
                    }
                    if (typeof(Component).IsAssignableFrom(type5))
                    {
                        bdi.sgReturnType = type5;
                        return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetComponentVarValue", new CodeTypeReference(type5)), new CodePrimitiveExpression(variable_Block.varName)));
                    }
                    if (typeof(UnityEngine.Object).IsAssignableFrom(type5))
                    {
                        bdi.sgReturnType = type5;
                        return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject2, "GetUnityObjectVarValue", new CodeTypeReference(type5)), new CodePrimitiveExpression(variable_Block.varName)));
                    }
                }
                return(new CodeMethodInvokeExpression(targetObject2, "GetVarValue", new CodePrimitiveExpression(variable_Block.varName)));
            }
            if (variable_Block.varType == plyVariablesType.Global)
            {
                CodeExpression targetObject3 = new CodeVariableReferenceExpression(BloxScriptGenerator.GetCleanGlobalVariableName(variable_Block.varName));
                Type           type6         = (bdi.fieldIdx == -1) ? bdi.owningBlock.def.contextType : bdi.owningBlock.ParameterTypes()[bdi.fieldIdx];
                if (type6 != null)
                {
                    plyVarValueHandler valueHandler2 = plyVar.ValueHandler;
                    Type type7 = (valueHandler2 != null) ? valueHandler2.GetType() : null;
                    if (type7 == typeof(plyVar_GameObject) || type7 == typeof(plyVar_Component))
                    {
                        if (typeof(GameObject).IsAssignableFrom(type6))
                        {
                            bdi.sgReturnType = type6;
                            return(new CodeMethodInvokeExpression(targetObject3, "GetGameObject"));
                        }
                        if (typeof(Component).IsAssignableFrom(type6))
                        {
                            bdi.sgReturnType = type6;
                            return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject3, "GetComponent", new CodeTypeReference(type6))));
                        }
                    }
                    else if (plyVar.ValueHandler.GetType() == typeof(plyVar_UnityObject))
                    {
                        bdi.sgReturnType = type6;
                        return(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(targetObject3, "GetObject", new CodeTypeReference(type6))));
                    }
                }
                return(new CodeMethodInvokeExpression(targetObject3, "GetValue"));
            }
            return(null);
        }
Пример #28
0
 public override string VarTypeName(plyVar target)
 {
     return("Float");
 }
Пример #29
0
 public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
 {
     if (target == objRefProxy && (target.objRefs == null || target.objRefs.Length == 0))
     {
         target.objRefs = new UnityEngine.Object[1];
     }
     objRefProxy.objRefs[objRefProxyIdx] = EditorGUI.ObjectField(rect, objRefProxy.objRefs[objRefProxyIdx], target.variableType, isOnSceneObject);
     return(false);
 }
Пример #30
0
        public override bool DrawEditor(Rect rect, bool isOnSceneObject, plyVar target, plyVar objRefProxy, int objRefProxyIdx)
        {
            plyVar_Gradient plyVar_Gradient = (plyVar_Gradient)target.ValueHandler;

            plyEdUtil.DrawGradientField(rect, plyVar_Gradient.storedValue);
            return(false);
        }