Beispiel #1
0
        public string GetPreviewString(RSTriggerInfo inTriggerContext, RSLibrary inLibrary)
        {
            using (PooledStringBuilder psb = PooledStringBuilder.Alloc())
            {
                var sb = psb.Builder;

                if (!Enabled)
                {
                    sb.Append("[Disabled] ");
                }

                if (!string.IsNullOrEmpty(Name))
                {
                    sb.Append(Name).Append(" :: ");
                }

                sb.Append(TriggerId.ToString(inLibrary));

                return(sb.ToString());
            }
        }
Beispiel #2
0
        public string GetPreviewString(RSTriggerInfo inTriggerContext, RSLibrary inLibrary)
        {
            switch (m_Type)
            {
            case InnerType.String:
                return(string.Format("\"{0}\"", m_StringValue));

            case InnerType.Color:
                return(ColorValue.ToString());

            case InnerType.Bool:
                return(BoolValue ? "true" : "false");

            case InnerType.Float:
                return(FloatValue.ToString());

            case InnerType.Int32:
                return(IntValue.ToString());

            case InnerType.Null:
                return("null");

            case InnerType.Vector2:
                return(AsVector2.ToString());

            case InnerType.Vector3:
                return(AsVector3.ToString());

            case InnerType.Vector4:
                return(AsVector4.ToString());

            case InnerType.EntityScope:
                return(EntityValue.GetPreviewString(inTriggerContext, inLibrary));

            case InnerType.GroupId:
                return(GroupIdValue.ToString(inLibrary));

            case InnerType.TriggerId:
                return(TriggerIdValue.ToString(inLibrary));

            case InnerType.Enum:
            {
                Type enumType = Type.GetType(m_StringValue);
                if (enumType == null)
                {
                    Debug.LogErrorFormat("Enum type {0} no longer exists", m_StringValue);
                    return(m_IntValue.ToString());
                }

                try
                {
                    return(Enum.ToObject(enumType, m_IntValue).ToString());
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                    Debug.LogErrorFormat("Enum {0} cannot be represented as type {1}", m_IntValue, enumType);
                    return(m_IntValue.ToString());
                }
            }

            case InnerType.Invalid:
                return("INVALID");

            default:
                ThrowInvalidCastException(m_Type, typeof(string));
                return(null);
            }
        }