示例#1
0
        public static string GetValueLabel(INamedVariable variable)
        {
            if (variable == null)
            {
                return("[null]");
            }
            if (variable.IsNone)
            {
                return("[none]");
            }
            if (variable.UseVariable)
            {
                return(variable.Name);
            }
            object rawValue = variable.RawValue;

            if (object.ReferenceEquals(rawValue, null))
            {
                return("null");
            }
            if (rawValue is string)
            {
                return("\"" + rawValue + "\"");
            }
            if (rawValue is Array)
            {
                return("Array");
            }
            return(variable.RawValue.ToString());
        }
示例#2
0
        void InitFsmVar()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null)
            {
                return;
            }

            if (go != cachedGO)
            {
                sourceFsm      = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
                sourceVariable = sourceFsm.FsmVariables.GetVariable(setValue.variableName);
                targetVariable = Fsm.Variables.GetVariable(setValue.variableName);

                setValue.Type = FsmUtility.GetVariableType(targetVariable);

                if (!string.IsNullOrEmpty(setValue.variableName) && sourceVariable == null)
                {
                    LogWarning("Missing Variable: " + setValue.variableName);
                }

                cachedGO = go;
            }
        }
示例#3
0
 public FsmVar(INamedVariable variable)
 {
     type         = variable.VariableType;
     ObjectType   = variable.ObjectType;
     variableName = variable.Name;
     GetValueFrom(variable);
 }
示例#4
0
 public SkillVar(INamedVariable variable)
 {
     this.type         = variable.VariableType;
     this.ObjectType   = variable.ObjectType;
     this.variableName = variable.Name;
     this.GetValueFrom(variable);
 }
        private static void DoVariableContextMenu(INamedVariable variable)
        {
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent(Strings.get_Menu_Copy_Value()), false, new GenericMenu.MenuFunction2(VariableEditor.CopyVariableValue), variable);
            genericMenu.AddItem(new GUIContent(Strings.get_Menu_Paste_Value()), false, new GenericMenu.MenuFunction2(VariableEditor.PasteVariableValue), variable);
            genericMenu.ShowAsContext();
        }
 private static void EndVariableEditor(INamedVariable variable)
 {
     EditorGUILayout.EndHorizontal();
     if (variable != null && VariableEditor.DebugVariables && variable.get_UseVariable() && !string.IsNullOrEmpty(variable.get_Name()))
     {
         SkillEditorGUILayout.ReadonlyTextField(variable.ToString(), new GUILayoutOption[0]);
     }
 }
示例#7
0
 private void UpdateType(INamedVariable sourceVar)
 {
     if (sourceVar == null)
     {
         Type = VariableType.Unknown;
         return;
     }
     Type       = sourceVar.VariableType;
     ObjectType = sourceVar.ObjectType;
 }
示例#8
0
        public static string GetValueLabel(INamedVariable variable)
        {
            if (variable == null)
            {
                return("[null]");
            }
            if (variable.IsNone)
            {
                return("[none]");
            }
            if (variable.UseVariable)
            {
                return(variable.Name);
            }
            var rawValue = variable.RawValue;

            if (rawValue == null)
            {
                return("null");
            }
            if (rawValue is string)
            {
                return("\"" + rawValue + "\"");
            }
            if (rawValue is Array)
            {
                return("Array");
            }
#if NETFX_CORE
            if (rawValue.GetType().IsValueType())
            {
                return(rawValue.ToString());
            }
#else
            if (rawValue.GetType().IsValueType)
            {
                return(rawValue.ToString());
            }
#endif
            var label      = rawValue.ToString();
            var classIndex = label.IndexOf('(');
            if (classIndex > 0)
            {
                return(label.Substring(0, label.IndexOf('(')));
            }
            return(label);
        }
示例#9
0
        private void InitFsmVar()
        {
            GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(gameObject);

            if (!(ownerDefaultTarget == null) && ownerDefaultTarget != cachedGO)
            {
                sourceFsm       = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, fsmName.Value);
                sourceVariable  = sourceFsm.FsmVariables.GetVariable(storeValue.variableName);
                targetVariable  = base.Fsm.Variables.GetVariable(storeValue.variableName);
                storeValue.Type = targetVariable.VariableType;
                if (!string.IsNullOrEmpty(storeValue.variableName) && sourceVariable == null)
                {
                    LogWarning("Missing Variable: " + storeValue.variableName);
                }
                cachedGO = ownerDefaultTarget;
            }
        }
示例#10
0
 private void InitFsmVar()
 {
     GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
     if (ownerDefaultTarget == null)
     {
         return;
     }
     if (ownerDefaultTarget != this.cachedGO)
     {
         this.sourceFsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value);
         this.sourceVariable = this.sourceFsm.FsmVariables.GetVariable(this.setValue.variableName);
         this.targetVariable = base.Fsm.Variables.GetVariable(this.setValue.variableName);
         this.setValue.Type = FsmUtility.GetVariableType(this.targetVariable);
         if (!string.IsNullOrEmpty(this.setValue.variableName) && this.sourceVariable == null)
         {
             this.LogWarning("Missing Variable: " + this.setValue.variableName);
         }
         this.cachedGO = ownerDefaultTarget;
     }
 }
示例#11
0
        private void InitFsmVar()
        {
            GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);

            if (ownerDefaultTarget == null)
            {
                return;
            }
            if (ownerDefaultTarget != this.cachedGO)
            {
                this.sourceFsm       = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value);
                this.sourceVariable  = this.sourceFsm.FsmVariables.GetVariable(this.storeValue.variableName);
                this.targetVariable  = base.Fsm.Variables.GetVariable(this.storeValue.variableName);
                this.storeValue.Type = FsmUtility.GetVariableType(this.targetVariable);
                if (!string.IsNullOrEmpty(this.storeValue.variableName) && this.sourceVariable == null)
                {
                    this.LogWarning("Missing Variable: " + this.storeValue.variableName);
                }
                this.cachedGO = ownerDefaultTarget;
            }
        }
示例#12
0
        void InitFsmVar()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null)
            {
                return;
            }

            if (go != cachedGO)
            {
                sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value);
                sourceVariable = sourceFsm.FsmVariables.GetVariable(storeValue.variableName);
                targetVariable = Fsm.Variables.GetVariable(storeValue.variableName);
                storeValue.Type = targetVariable.VariableType;

                if (!string.IsNullOrEmpty(storeValue.variableName) && sourceVariable == null)
                {
                    LogWarning("Missing Variable: " + storeValue.variableName);
                }

                cachedGO = go;
            }
        }
示例#13
0
        public static VariableType GetVariableType(INamedVariable variable)
        {
            if (variable == null)
            {
                return(VariableType.Unknown);
            }
            Type type = variable.GetType();

            if (object.ReferenceEquals(type, typeof(FsmMaterial)))
            {
                return(VariableType.Material);
            }
            if (object.ReferenceEquals(type, typeof(FsmTexture)))
            {
                return(VariableType.Texture);
            }
            if (object.ReferenceEquals(type, typeof(FsmFloat)))
            {
                return(VariableType.Float);
            }
            if (object.ReferenceEquals(type, typeof(FsmInt)))
            {
                return(VariableType.Int);
            }
            if (object.ReferenceEquals(type, typeof(FsmBool)))
            {
                return(VariableType.Bool);
            }
            if (object.ReferenceEquals(type, typeof(FsmString)))
            {
                return(VariableType.String);
            }
            if (object.ReferenceEquals(type, typeof(FsmGameObject)))
            {
                return(VariableType.GameObject);
            }
            if (object.ReferenceEquals(type, typeof(FsmVector2)))
            {
                return(VariableType.Vector2);
            }
            if (object.ReferenceEquals(type, typeof(FsmVector3)))
            {
                return(VariableType.Vector3);
            }
            if (object.ReferenceEquals(type, typeof(FsmRect)))
            {
                return(VariableType.Rect);
            }
            if (object.ReferenceEquals(type, typeof(FsmQuaternion)))
            {
                return(VariableType.Quaternion);
            }
            if (object.ReferenceEquals(type, typeof(FsmColor)))
            {
                return(VariableType.Color);
            }
            if (object.ReferenceEquals(type, typeof(FsmObject)))
            {
                return(VariableType.Object);
            }
            if (object.ReferenceEquals(type, typeof(FsmEnum)))
            {
                return(VariableType.Enum);
            }
            if (object.ReferenceEquals(type, typeof(FsmArray)))
            {
                return(VariableType.Array);
            }
            return(VariableType.Unknown);
        }
示例#14
0
        public void ApplyValueTo(INamedVariable targetVariable)
        {
            if (targetVariable == null)
            {
                return;
            }
            switch (this.type)
            {
            case VariableType.Unknown:
                return;

            case VariableType.Float:
                ((SkillFloat)targetVariable).Value = this.floatValue;
                return;

            case VariableType.Int:
                ((SkillInt)targetVariable).Value = this.intValue;
                return;

            case VariableType.Bool:
                ((SkillBool)targetVariable).Value = this.boolValue;
                return;

            case VariableType.GameObject:
                ((SkillGameObject)targetVariable).Value = (this.objectReference as GameObject);
                return;

            case VariableType.String:
                ((SkillString)targetVariable).Value = this.stringValue;
                return;

            case VariableType.Vector2:
                ((SkillVector2)targetVariable).Value = this.vector2Value;
                return;

            case VariableType.Vector3:
                ((SkillVector3)targetVariable).Value = this.vector3Value;
                return;

            case VariableType.Color:
                ((SkillColor)targetVariable).Value = this.colorValue;
                return;

            case VariableType.Rect:
                ((SkillRect)targetVariable).Value = this.rectValue;
                return;

            case VariableType.Material:
                ((SkillMaterial)targetVariable).Value = (this.objectReference as Material);
                return;

            case VariableType.Texture:
                ((SkillTexture)targetVariable).Value = (this.objectReference as Texture);
                return;

            case VariableType.Quaternion:
                ((SkillQuaternion)targetVariable).Value = this.quaternionValue;
                return;

            case VariableType.Object:
                ((SkillObject)targetVariable).Value = this.objectReference;
                return;

            case VariableType.Array:
                ((SkillArray)targetVariable).CopyValues(this.arrayValue);
                return;

            case VariableType.Enum:
                ((SkillEnum)targetVariable).Value = this.EnumValue;
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#15
0
        public static VariableType GetVariableType(INamedVariable variable)
        {
            if (variable == null)
            {
                return(VariableType.Unknown);
            }
            Type type = variable.GetType();

            if (object.ReferenceEquals(type, typeof(SkillMaterial)))
            {
                return(VariableType.Material);
            }
            if (object.ReferenceEquals(type, typeof(SkillTexture)))
            {
                return(VariableType.Texture);
            }
            if (object.ReferenceEquals(type, typeof(SkillFloat)))
            {
                return(VariableType.Float);
            }
            if (object.ReferenceEquals(type, typeof(SkillInt)))
            {
                return(VariableType.Int);
            }
            if (object.ReferenceEquals(type, typeof(SkillBool)))
            {
                return(VariableType.Bool);
            }
            if (object.ReferenceEquals(type, typeof(SkillString)))
            {
                return(VariableType.String);
            }
            if (object.ReferenceEquals(type, typeof(SkillGameObject)))
            {
                return(VariableType.GameObject);
            }
            if (object.ReferenceEquals(type, typeof(SkillVector2)))
            {
                return(VariableType.Vector2);
            }
            if (object.ReferenceEquals(type, typeof(SkillVector3)))
            {
                return(VariableType.Vector3);
            }
            if (object.ReferenceEquals(type, typeof(SkillRect)))
            {
                return(VariableType.Rect);
            }
            if (object.ReferenceEquals(type, typeof(SkillQuaternion)))
            {
                return(VariableType.Quaternion);
            }
            if (object.ReferenceEquals(type, typeof(SkillColor)))
            {
                return(VariableType.Color);
            }
            if (object.ReferenceEquals(type, typeof(SkillObject)))
            {
                return(VariableType.Object);
            }
            if (object.ReferenceEquals(type, typeof(SkillEnum)))
            {
                return(VariableType.Enum);
            }
            if (object.ReferenceEquals(type, typeof(SkillArray)))
            {
                return(VariableType.Array);
            }
            return(VariableType.Unknown);
        }
示例#16
0
        public void ApplyValueTo(INamedVariable targetVariable)
        {
            if (targetVariable != null)
            {
                switch (type)
                {
                case VariableType.Float:
                    ((FsmFloat)targetVariable).Value = floatValue;
                    break;

                case VariableType.Int:
                    ((FsmInt)targetVariable).Value = intValue;
                    break;

                case VariableType.Bool:
                    ((FsmBool)targetVariable).Value = boolValue;
                    break;

                case VariableType.GameObject:
                    ((FsmGameObject)targetVariable).Value = objectReference as GameObject;
                    break;

                case VariableType.String:
                    ((FsmString)targetVariable).Value = stringValue;
                    break;

                case VariableType.Vector2:
                    ((FsmVector2)targetVariable).Value = vector2Value;
                    break;

                case VariableType.Vector3:
                    ((FsmVector3)targetVariable).Value = vector3Value;
                    break;

                case VariableType.Color:
                    ((FsmColor)targetVariable).Value = colorValue;
                    break;

                case VariableType.Rect:
                    ((FsmRect)targetVariable).Value = rectValue;
                    break;

                case VariableType.Material:
                    ((FsmMaterial)targetVariable).Value = objectReference as Material;
                    break;

                case VariableType.Texture:
                    ((FsmTexture)targetVariable).Value = objectReference as Texture;
                    break;

                case VariableType.Quaternion:
                    ((FsmQuaternion)targetVariable).Value = quaternionValue;
                    break;

                case VariableType.Object:
                    ((FsmObject)targetVariable).Value = objectReference;
                    break;

                case VariableType.Enum:
                    ((FsmEnum)targetVariable).Value = EnumValue;
                    break;

                case VariableType.Array:
                    ((FsmArray)targetVariable).CopyValues(arrayValue);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();

                case VariableType.Unknown:
                    break;
                }
            }
        }
示例#17
0
        public void GetValueFrom(INamedVariable variable)
        {
            if (variable != null)
            {
                switch (type)
                {
                case VariableType.Float:
                    floatValue = ((FsmFloat)variable).Value;
                    break;

                case VariableType.Int:
                    intValue = ((FsmInt)variable).Value;
                    break;

                case VariableType.Bool:
                    boolValue = ((FsmBool)variable).Value;
                    break;

                case VariableType.GameObject:
                    objectReference = ((FsmGameObject)variable).Value;
                    break;

                case VariableType.String:
                    stringValue = ((FsmString)variable).Value;
                    break;

                case VariableType.Vector2:
                    vector2Value = ((FsmVector2)variable).Value;
                    break;

                case VariableType.Vector3:
                    vector3Value = ((FsmVector3)variable).Value;
                    break;

                case VariableType.Color:
                    colorValue = ((FsmColor)variable).Value;
                    break;

                case VariableType.Rect:
                    rectValue = ((FsmRect)variable).Value;
                    break;

                case VariableType.Material:
                    objectReference = ((FsmMaterial)variable).Value;
                    break;

                case VariableType.Texture:
                    objectReference = ((FsmTexture)variable).Value;
                    break;

                case VariableType.Quaternion:
                    quaternionValue = ((FsmQuaternion)variable).Value;
                    break;

                case VariableType.Object:
                    objectReference = ((FsmObject)variable).Value;
                    break;

                case VariableType.Enum:
                    EnumValue = ((FsmEnum)variable).Value;
                    break;

                case VariableType.Array:
                    arrayValue = new FsmArray((FsmArray)variable);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();

                case VariableType.Unknown:
                    break;
                }
            }
        }
示例#18
0
        public void GetValueFrom(INamedVariable variable)
        {
            if (variable == null)
            {
                return;
            }
            switch (this.type)
            {
            case VariableType.Unknown:
                return;

            case VariableType.Float:
                this.floatValue = ((SkillFloat)variable).Value;
                return;

            case VariableType.Int:
                this.intValue = ((SkillInt)variable).Value;
                return;

            case VariableType.Bool:
                this.boolValue = ((SkillBool)variable).Value;
                return;

            case VariableType.GameObject:
                this.objectReference = ((SkillGameObject)variable).Value;
                return;

            case VariableType.String:
                this.stringValue = ((SkillString)variable).Value;
                return;

            case VariableType.Vector2:
                this.vector2Value = ((SkillVector2)variable).Value;
                return;

            case VariableType.Vector3:
                this.vector3Value = ((SkillVector3)variable).Value;
                return;

            case VariableType.Color:
                this.colorValue = ((SkillColor)variable).Value;
                return;

            case VariableType.Rect:
                this.rectValue = ((SkillRect)variable).Value;
                return;

            case VariableType.Material:
                this.objectReference = ((SkillMaterial)variable).Value;
                return;

            case VariableType.Texture:
                this.objectReference = ((SkillTexture)variable).Value;
                return;

            case VariableType.Quaternion:
                this.quaternionValue = ((SkillQuaternion)variable).Value;
                return;

            case VariableType.Object:
                this.objectReference = ((SkillObject)variable).Value;
                return;

            case VariableType.Array:
                this.arrayValue = new SkillArray((SkillArray)variable);
                return;

            case VariableType.Enum:
                this.EnumValue = ((SkillEnum)variable).Value;
                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }